#include <bits/stdc++.h>
using namespace std;
const int N = 100005, D = 50;
int n, m, d;
char ok[N][D + 5];
inline int id(int pos, int num) { return (pos - 1) * d + num; }
struct Graph {
  int head[N * D], nxt[N * D], v[N * D], ptr;
  inline void add_edge(int uu, int vv) {
    v[ptr] = vv;
    nxt[ptr] = head[uu];
    head[uu] = ptr++;
  }
  Graph() {
    memset(head, -1, sizeof(head));
    memset(nxt, -1, sizeof(nxt));
  }
} g, ng;
int dfn[N * D], low[N * D], idx, scc_idx, scc[N * D], val[N * D];
int deg[N * D];
stack<int> stk;
bool vis[N * D], has[N * D];
int dp[N * D];
vector<int> tmp;
void tarjan(int pos) {
  dfn[pos] = low[pos] = ++idx;
  vis[pos] = 1;
  stk.push(pos);
  for (int i = g.head[pos]; i != -1; i = g.nxt[i])
    if (!dfn[g.v[i]]) {
      tarjan(g.v[i]);
      low[pos] = min(low[pos], low[g.v[i]]);
    } else if (vis[g.v[i]])
      low[pos] = min(low[pos], dfn[g.v[i]]);
  if (dfn[pos] == low[pos]) {
    int cnt = 0;
    ++scc_idx;
    while (!stk.empty()) {
      int nd = stk.top();
      stk.pop();
      scc[nd] = scc_idx;
      vis[nd] = 0;
      if (ok[nd / d + 1][nd % d] == '1') {
        if (!has[nd / d]) {
          ++cnt;
          has[nd / d] = 1;
          tmp.push_back(nd / d);
        }
      }
      if (nd == pos) break;
    }
    while (!tmp.empty()) has[tmp.back()] = 0, tmp.pop_back();
    val[scc_idx] = cnt;
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m >> d;
  for (int i = 1; i <= m; i++) {
    int t1, t2;
    cin >> t1 >> t2;
    for (int j = 0; j < d; j++) g.add_edge(id(t1, j), id(t2, (j + 1) % d));
  }
  for (int i = 1; i <= n; i++) cin >> ok[i];
  tarjan(id(1, 0));
  for (int i = 0; i < n * d; i++)
    for (int j = g.head[i]; j != -1; j = g.nxt[j])
      if (scc[i] && scc[g.v[j]] && scc[i] != scc[g.v[j]])
        ng.add_edge(scc[i], scc[g.v[j]]), ++deg[scc[g.v[j]]];
  queue<int> q;
  q.push(scc[id(1, 0)]);
  dp[scc[id(1, 0)]] = val[scc[id(1, 0)]];
  int ans = 0;
  while (!q.empty()) {
    int nd = q.front();
    q.pop();
    ans = max(ans, dp[nd]);
    for (int i = ng.head[nd]; i != -1; i = ng.nxt[i]) {
      int vv = ng.v[i];
      dp[vv] = max(dp[vv], val[vv] + dp[nd]);
      if (!--deg[vv]) q.push(vv);
    }
  }
  cout << ans << endl;
  return 0;
}
