//Pascal's Travels#include
#include
int main(){ int n,i,j,t; long long dp[35][35]; char b[35][35]; while(scanf("%d",&n)!=EOF&&n!=-1){ getchar(); for(i=0;i