import java.util.Scanner;
public class Main {
void frontAndBack(long raise,int k)
{
int length
=String.
valueOf(raise
).
length();
long frontTemp=raise;
String front
= String.
valueOf((int)(frontTemp
/Math.
pow(10, length
-1))).
toString(); frontTemp
=(long) (frontTemp
%Math.
pow(10, length
-1));
for(int i=1;i<length && i<k;i++)
{
long quo,rem;
quo
=(long) (frontTemp
/Math.
pow(10, length
-i
-1)); rem
=(long) (frontTemp
%Math.
pow(10, length
-i
-1));
front
=front
+String.
valueOf(quo
).
toString(); frontTemp=rem;
}
long backTemp=raise;
backTemp
=(long) (backTemp
/Math.
pow(10,
1));
for(int i=1;i<length && i<k;i++)
{
long quo,rem;
quo
=(long)(backTemp
/Math.
pow(10,
1)); rem
=(long)(backTemp
%Math.
pow(10,
1));
back
=String.
valueOf(rem
).
toString()+back
; backTemp=quo;
}
}
void calc()
{
Scanner in
=new Scanner
(System.
in);
long n
=Long.
parseLong(temp1
);
long raise
=(long) Math.
pow(n,n
);
new Main().frontAndBack(raise,k);
}
public static void main
(String[] args
) { Scanner in
=new Scanner
(System.
in);
for(int i
=0;i
<Integer.
parseInt(t
);i
++) {
new Main().calc();
}
}
}
aW1wb3J0IGphdmEudXRpbC5TY2FubmVyOwoKcHVibGljIGNsYXNzIE1haW4gewogICAgdm9pZCBmcm9udEFuZEJhY2sobG9uZyByYWlzZSxpbnQgaykKCXsKCQlpbnQgbGVuZ3RoPVN0cmluZy52YWx1ZU9mKHJhaXNlKS5sZW5ndGgoKTsKCgkJbG9uZyBmcm9udFRlbXA9cmFpc2U7CgoJCVN0cmluZyBmcm9udCA9IFN0cmluZy52YWx1ZU9mKChpbnQpKGZyb250VGVtcC9NYXRoLnBvdygxMCwgbGVuZ3RoLTEpKSkudG9TdHJpbmcoKTsKCQlmcm9udFRlbXA9KGxvbmcpIChmcm9udFRlbXAlTWF0aC5wb3coMTAsIGxlbmd0aC0xKSk7CgoJCWZvcihpbnQgaT0xO2k8bGVuZ3RoICYmIGk8aztpKyspCgkJewoJCQlsb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