awk '
{
x[$1]=x[$1] " " $2; # Append 2nd field to contents of x[$1] (followed by a space)
y[$2]=y[$2] " " $1; # Append 1st field to contents of y[$1] (followed by a space)
}
# Now: The array "x" contains all the lines keyed by the first field.
# The array "y" contains all the lines keyed by the second field.
END {
for (k in x) print k,x[k] >"OUTPUT1";
for (k in y) print k,y[k] >"OUTPUT2";
}' INPUT