only if column1 equals this print that

I have text file with hundreds of lines, space delimited, each line has the same amount of "columns" and the same amount of characters in each, Column 1, Column 2, and Column 3.
I need a script that will print all columns of the "current" line along with the last two columns of the next line ONLY IF the first columns are equal.
Another way of putting it...

If Column1CurrentLine equals Column1NextLine
print AllOfCurrentLine Column2NextLine Column3NextLine

So my input has 3 columns and my output would have 5 total but only 3 in some lines?

input:

A abc def
A hij klm
A nop qrs
B abc def
B hij klm
C aaa bbb

output:

A abc def hij klm
A hij klm nop qrs
A nop qrs
B abc def hij klm
B hij klm
C aaa bbb

Remember the previous line, and print that if the current line doesn't match. If the current line does match the previous line, print a combined line. As a special case, print the last one you remembered at end of file.

Actually the remembering for the next round has to happen right at the end of the main loop, and the beginning of the loop is conditional on there being a remembered value.

awk '{ if (r[0]) {
    if ($1 != r[0]) print r[0], r[1], r[2]; 
    else print $1, r[1], r[2], $2, $3;
  }
  r[0] = $1; r[1] = $2; r[2] = $3; }
END { print r[0], r[1], r[2]; }' file

Here's a Python version.

It expects to be run as such: scriptname.py filename.txt

#!/usr/bin/env python

import sys

file = sys.argv[1]

input = open(file, 'r')

previous = ""

for line in input:

    line = line.rstrip()

    if not previous == "":
        fields = line.split(" ")
        prev = previous.split(" ")
        
        if fields[0] == prev[0]:
            prev.extend(fields[1:])

        print " ".join(prev)

    previous = line

print previous

line=`cat filename|wc -l`
nawk -v l="$line" '{
if (t=="")
{
	t=$0
	tf=$1
	continue
}
if(t!="" && $1!=tf)
{
	print t
	t=$0
	tf=$1
}
else if(t!="" && $1==tf)
{
	print t" "$2" "$3
	t=$0
	tf=$1
}
if(NR==l)
	print
}' filename