#include <stdio.h> #include <string.h> int main(int argc, char* argv[]) { #ifdef __MYLOCAL freopen("in.txt","r",stdin); #endif int t,n; scanf("%d",&t); while(t--) { scanf("%d",&n); int all = 1, a = n % 10; while(n > 0) { n % 2 == 1 ? all = all * a % 10 : NULL; n >>= 1; a = a * a % 10; } printf("%d ",all); } return 0; }