#include <bits/stdc++.h>
using namespace std;
const int NN = 1e5 + 10, N = NN * 50;
int n, m, k;
int head[N], head2[N], cnt, cnt2, dcnt, dfn[N], low[N];
long long open[N];
struct EDGE {
  int y, nex;
} edge[N], edge2[N];
inline int trans(int i, int j) { return j * n + i; }
inline void add(int x, int y) {
  edge[++cnt].y = y;
  edge[cnt].nex = head[x];
  head[x] = cnt;
}
inline void add2(int x, int y) {
  edge2[++cnt2].y = y;
  edge2[cnt2].nex = head2[x];
  head2[x] = cnt2;
}
bool vis[N], ins[N];
stack<int> s, q;
int fen, bel[N], val[N];
inline void tarjan(int x) {
  dfn[x] = low[x] = ++dcnt;
  ins[x] = 1, s.push(x);
  for (int i = head[x]; i; i = edge[i].nex) {
    int y = edge[i].y;
    if (!dfn[y]) {
      tarjan(y);
      low[x] = min(low[x], low[y]);
    } else if (ins[y]) {
      low[x] = min(low[x], dfn[y]);
    }
  }
  if (low[x] != dfn[x]) return;
  ++fen;
  int now;
  do {
    now = s.top();
    s.pop();
    ins[now] = 0, bel[now] = fen;
    int x = (now - 1) % n + 1, day = (now - 1) / n;
    if (!vis[x] && (open[x] >> day & 1)) {
      val[fen]++, vis[x] = true;
      q.push(x);
    }
  } while (now != x);
  while (!q.empty()) vis[q.top()] = false, q.pop();
}
int f[N];
int dfs(int x) {
  if (vis[x]) return f[x];
  vis[x] = 1;
  for (int i = head2[x]; i; i = edge2[i].nex) {
    int y = edge2[i].y;
    f[x] = max(f[x], dfs(y));
  }
  return f[x] += val[x];
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    for (int j = 0; j < k; j++) {
      add(trans(x, j), trans(y, (j + 1) % k));
    }
  }
  char ch;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < k; j++) {
      ch = getchar();
      while (!(ch == '0' || ch == '1')) ch = getchar();
      open[i] |= (ch - '0') * (1ll << j);
    }
  }
  tarjan(1);
  for (int i = 1; i <= n * k; i++) {
    if (!dfn[i]) continue;
    int b = bel[i];
    for (int j = head[i]; j; j = edge[j].nex) {
      int y = edge[j].y;
      if (!dfn[y]) continue;
      y = bel[y];
      if (b != y) {
        add2(b, y);
      }
    }
  }
  printf("%d\n", dfs(bel[1]));
}
