#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
const long long G = 50e5 + 5;
long long a, b, k;
int fir[G], ver[G], lst[G], nxt[G];
vector<int> g[G];
int us[G], cmp[G], ts[G];
pair<int, int> kek[G];
int szt = 0;
int szv = 0;
void add_edge(int x, int y) {
  if (fir[x] == -1) {
    fir[x] = szv;
  } else {
    nxt[lst[x]] = szv;
  }
  lst[x] = szv;
  ver[szv++] = y;
}
int main() {
  cin.tie(0);
  cout.tie(0);
  cin.sync_with_stdio(0);
  cout.sync_with_stdio(0);
  ;
  cin >> a >> b >> k;
  memset(fir, -1, sizeof(fir));
  ;
  memset(nxt, -1, sizeof(nxt));
  ;
  for (int q = 0; q < b; q++) {
    int x, y;
    cin >> x >> y;
    x--, y--;
    for (int w = 0; w < k; w++) {
      add_edge(x * k + w, y * k + (w + 1) % k);
      g[y * k + (w + 1) % k].push_back(x * k + w);
    }
  }
  memset(us, 0, sizeof(us));
  ;
  for (int q = 0; q < a * k; q++) {
    if (us[q]) continue;
    int szk = 0;
    kek[szk++] = {q, fir[q]};
    us[q] = 1;
    for (; szk;) {
      pair<int, int> &p = kek[szk - 1];
      if (p.second == -1) {
        ts[szt++] = p.first;
        szk--;
        continue;
      }
      for (; p.second != -1; p.second = nxt[p.second]) {
        int h = ver[p.second];
        if (!us[h]) {
          us[h] = 1;
          kek[szk++] = {h, fir[h]};
          break;
        }
      }
    }
  }
  assert(szt == a * k);
  reverse(ts, ts + a * k);
  int cn = 0;
  memset(us, 0, sizeof(us));
  ;
  for (int q = 0; q < a * k; q++) {
    int i = ts[q];
    if (us[i]) continue;
    int szk = 0;
    kek[szk++] = {i, 0};
    us[i] = 1;
    for (; szk;) {
      int v = kek[--szk].first;
      cmp[v] = cn;
      for (int h : g[v]) {
        if (!us[h]) {
          us[h] = 1;
          kek[szk++] = {h, 0};
        }
      }
    }
    cn++;
  }
  for (int q = 0; q < G; q++) g[q].clear();
  for (int q = 0; q < a * k; q++) {
    for (int w = fir[q]; w != -1; w = nxt[w]) {
      int h = ver[w];
      long long x = cmp[q], y = cmp[h];
      if (x != y) {
        assert(x < y);
        g[x].push_back(y);
      }
    }
  }
  for (int q = 0; q < cn; q++) {
    sort(g[q].begin(), g[q].end());
    g[q].erase(unique(g[q].begin(), g[q].end()), g[q].end());
  }
  int dp[cn];
  memset(dp, 0, sizeof(dp));
  ;
  memset(us, 0, sizeof(us));
  ;
  int T = 0;
  for (int q = 0; q < a; q++) {
    string t;
    cin >> t;
    T++;
    for (int w = 0; w < k; w++) {
      if (t[w] == '0') continue;
      if (us[cmp[q * k + w]] != T) {
        us[cmp[q * k + w]] = T;
        dp[cmp[q * k + w]] += t[w] - '0';
      }
    }
  }
  for (int q = cn - 1; q >= 0; q--) {
    int mx = 0;
    for (int h : g[q]) {
      mx = max(mx, dp[h]);
    }
    dp[q] += mx;
  }
  cout << dp[cmp[0]];
}
