Print first row of column a, last row of column b if column a has the same value

I have a table with this structure:

cola colb colc
1 19 lemon
20 31 lemon
32 100 lemon
159 205 cherries
210 500 cherries

and need to parse it into this format:

cola colb colc
1 100 lemon
159 500 cherries

So I need the first row of cola and the last row of colb if colc has the same pattern.

awk 'a[$3]++' 

gives me only the first rows and I cannot find a solution for the last row.

awk '
        ! ( $3 in A_min ) {
                A_min[$3] = $1
        }
        {
                A_min[$3] = ( A_min[$3] < $1 ? A_min[$3] : $1 )
                A_max[$3] = ( A_max[$3] > $2 ? A_max[$3] : $2 )
        }
        END {
                for ( k in A_min )
                        print A_min[k], A_max[k], k
        }
' file

Are all of the lines in your table with the same colc values adjacent (as in you sample) or can they appear on separated lines?

Are values in cola and colb always in increasing order in your table (as in your sample) or can they appear in random order?

Where is you table located? (In an array, in a file, in a database, etc.?)

If you have a problem, why don't you try to write some code to solve that problem? Why do you expect to find the solution to all of your problems without writing any code of your own? Why do you think that an awk script that never looks at $1 or $2 could be used to print minimum values of $1 and maximum values of $2 ?

echo 1 1 ! | awk 'NR==1 {print; next} ! l[$NF]++ {f[$NF]=$1; if (s) print f[w], s, w} {s=$2; w=$NF}' infile -