#include #include #include using namespace std; const int MAXN=1000+5; int T; int a[MAXN],b[MAXN]; int n,m; int gcd(int x,int y){return y?gcd(y,x%y):x;} int main() { scanf("%d",&T); while(T--) { scanf("%d",&n); for(int i=0;i0&&a[m]==0) m--; while(n>0&&b[n]==0) n--; if(m>n||b[n]==0){printf("1/0\n");continue;} if(a[m]==0||n>m){printf("0/1\n");continue;} int d=gcd(a[m],b[n]); printf("%d/%d\n",a[m]/d,b[n]/d); } return 0; }