#include<bits/stdc++.h>
using namespace std;
int n,a[10],ans=0,c,v,b,x,m;
bool Chk(int l,int r){
if(l==r) return true;
while(l%10==r%10) r/=10,l/=10;
if(l/10==r/10) return false;
if(l/100==r/100&&(max(l,r)-min(l,r))%11==0) return false;
return true;
}
int main(){
// freopen("lock.in","r",stdin);
// freopen("lock.out","w",stdout);
cin>>n;
for(int i=1;i<=n;i++){
cin>>c>>v>>b>>x>>m;
a[i]=c*10000+v*1000+b*100+x*10+m;
} if(n==1){
cout<<81;
return 0;
} for(int i=0;i<=99999;i++){
bool f=true;
for(int p=1;p<=n;p++){
if(Chk(i,a[p])) f=false;
} if(f) ans++;
} cout<<ans;
return 0;
}
最后一个点没过,求调!!!!!!!