#include<iostream>
#include<queue>
#include<algorithm>
#include<vector>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)

const int N = 1000;
const int M = 100;
char m[N][N+20];
char in[M][M+20];
char *ptr[N];
int atm[N][N+20];

void decode(int c,string &in,char *pt){
  int p=in.size()*6-1;
  for(int i=in.size()-1;i>=0;i--){
    int val;
    if (isupper(in[i]))val=in[i]-'A';
    else if (islower(in[i]))val=in[i]-'a' + 26;
    else if (isdigit(in[i]))val=in[i]-'0' + 52;
    else if (in[i] == '+')val=62;
    else if (in[i] == '/')val=63;
    rep(j,6){
      pt[p--]=val%2?'1':'0';
      val/=2;
    }
  }
  pt[c]='\0';
}

struct PMA{
  PMA *next[3];//next[0] is for fail, 0x100 = 256
  int id;
  vector<int> ac;
  PMA(){fill(next,next+3,(PMA*)0);id=-1;}
};

PMA *buildPMA(char *p[M],int size,int *acdata){
  PMA* root = new PMA;
  int cnt=0;
  rep(i,size){
    PMA *t = root;
    for(int j=0;p[i][j] != '\0';j++){
      char c=p[i][j]-'0'+1;
      if (t->next[c] == NULL)t->next[c]=new PMA;
      t=t->next[c];
    }
    if (t->id == -1)t->id=cnt++;
    acdata[i]=t->id;
    t->ac.push_back(t->id);
  }
  queue<PMA*> Q;
  REP(i,1,3){
    char c=i;
    if (root->next[c]){
      root->next[c]->next[0]=root;
      Q.push(root->next[c]);
    }else root->next[c]=root;
  }
  while(!Q.empty()){
    PMA *t = Q.front();Q.pop();
    for(int c='0'-'0'+1;c <= '1'-'0'+1;c++){
      if (t->next[c]){
	Q.push(t->next[c]);
	PMA *r = t->next[0];
	while(!r->next[c])r=r->next[0];
	t->next[c]->next[0]=r->next[c];
	copy(r->next[c]->ac.begin(),r->next[c]->ac.end(),
	     back_inserter(t->next[c]->ac));
      }
    }
  }
  return root;
}

void match(PMA *r,char *tar,int *res){
  for(int i=0;tar[i] != '\0';i++){
    char c=tar[i]-'0'+1;
    while(!r->next[c])r=r->next[0];
    r=r->next[c];
    rep(j,r->ac.size()){
      //res[r->ac[j]]++;
      //res[r->ac[j]]=i;
      res[i]=r->id;//ac[j];
    }
  }
}

int kmp(int p1,int* text,int p2,int* word){
  static int table[N];
  int i=2,j=0;//i:searching word j:backtracking point
  table[0]=-1;//
  table[1]=0;//
  while(i <= p2){//make table
    if ( word[i-1] == word[j]){
      table[i]=j+1;
      i++;
      j++;
    }else if ( j > 0){
      j = table[j];
    }else {
      table[i]=0;
      i++;
    }
  }
  //the main part of KMP algorithm
  int pos;//
  int m=0;//
  int cnt=0;
  i = 0;//
  while(m+i <p1){
    if (word[i] == text[m+i]){
      i++;
      if ( i == p2){
	//return m;
	cnt++;
	m=m+i-table[i];
	if (i>0)i=table[i];
      }
    }else {
      m = m+i-table[i];
      if (i > 0)i = table[i];
    }
  }
  return cnt;
}

char pat[8][M][M+2];//8 pattern

int compute(int r,int c,int p,int cur){
  int ret=0;
  static int ac[M+10],tres[N+10];
  rep(i,p)ptr[i]=pat[cur][i];
  PMA *root = buildPMA(ptr,p,ac);
  rep(i,r){
    rep(j,c)tres[j]=-1;
    match(root,m[i],tres);
    rep(j,c)atm[i][j]=tres[j];
  }
  rep(j,c){
    rep(i,r)tres[i]=atm[i][j];
    ret+=kmp(r,tres,p,ac);
  }
  return ret;
}

void rotate(int n,int cur){
  static char tmp[M][M];
  rep(i,n)rep(j,n)tmp[i][j]=pat[cur-1][i][j];
  rep(i,n){
    rep(j,n){
      pat[cur][n-1 -j][i]=tmp[i][j];
    }
  }
}
  
void mirror(int n,int cur){
  rep(i,n){
    rep(j,n/2)swap(pat[cur][i][j],pat[cur][i][n-1-j]);
  }
}

bool issame(int n,int cur,int tar){
  rep(i,n){
    rep(j,n)if (pat[cur][i][j] != pat[tar][i][j])return false;
  }
  return true;
}

int solve(int r,int c,int p){
  int ret=0;
  bool check[8]={false};
  fill(check,check+8,true);
  rep(k,8){
    rep(i,p)pat[k][i][p]='\0';
  }
  rep(i,p){
    rep(j,p)pat[0][i][j]=pat[4][i][j]=in[i][j];
  }
  REP(i,1,4)rotate(p,i);
  mirror(p,4);
  REP(i,5,8)rotate(p,i);

  rep(i,8){
    if (!check[i])continue;
    REP(j,i+1,8){
      if (issame(p,i,j))check[j]=false;
    }
  }

  rep(i,8){
    if (check[i])ret+=compute(r,c,p,i);
  }
  return ret;
}

main(){
  int c,r,p;
  while(cin>>c>>r>>p && c){
    rep(i,r){
      string tmp;
      cin>>tmp;
      decode(c,tmp,m[i]);
    }

    rep(i,p){
      string tmp;
      cin>>tmp;
      decode(p,tmp,in[i]);
    }

    cout << solve(r,c,p) << endl;
  }
  return false;
}

Measured memory_bytes: 14000