Given a positive integer N, you should output the leftmost digit of N^N.
Input
The input contains several test cases. The first line of the input is a single integer T which is the number of test cases. T test cases follow. Each test case contains a single positive integer N(1<=N<=1,000,000,000).
Output
For each test case, you should output the leftmost digit of N^N.
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int main()
{
int n,t,x,ans;
double y;
cin>>t;
while(t--)
{
cin>>n;
x=n*log10(n)+1;
y=n*log10(n)+1-x;
ans=pow(10,y);
cout<<ans<<endl;
}
return 0;
}