When playing music consisting of two or more parts, it is necessary to balance the relative volumes of the notes. The melody is usually played louder than the accompanying parts. Where the melody occurs on the 1st and 2nd strings, this can be achieved by playing the melody notes rest stroke, while playing the lower parts free stroke.
Here are two pieces to help you with this technique. The notes with their stems pointing up are played rest stroke with m and a, while the notes with their stems pointing down are played free stroke with p and i.
Notice the key signature of G major, reminding you to play all F notes as F#.
In this piece, rest stroke is used for the first line of the melody. It cannot be used for the second line, because the harmony notes are on an adjacent string and would be stopped from sounding if rest stroke were used. It is often up to the performer to decide where to use rest stroke and where to use free stroke.