Converting Pivot file to flat file

I have a file in this format.
P1 P2 P3.........................
A001 v11 v21 v31......................
A002 v12 v22 v32............................
A003 v13 v23 v33..........................
A004 v14 v24 v34..............................
.
.
.
A00n

This has to be flattened in this format

A001 P1 v11
A001 P2 v21
A001 P3 v31
A001 P4 v41
...
...
...

Please let me know if ther is a easy way in awk to do it?

Kumar

Maybe...

#! /usr/bin/ksh

read one
while read field line ; do
        echo "$field ${one%% *} $line"
        one=${one#* }
done
exit 0

or with awk:

nawk -f vs.awk myFile.txt

vs.awk:

FNR == 1 { n=split("1 " $0, arr, FS); next }
{
  for(i=2; i <= n; i++)
    print $1, arr, $i
}