#include <bits/stdc++.h>
#pragma GCC optimize(2)
#pragma warning(disable : 4996)
using namespace std;
namespace Bigcat {
template <typename T>
inline void max_s(T& a, const T& b) {
  a = max(a, b);
}
template <typename T>
inline void min_s(T& a, const T& b) {
  a = min(a, b);
}
template <typename T>
void sort_v(T& x) {
  sort(x.begin(), x.end());
}
template <typename T>
void erase_dup(T& x) {
  x.erase(unique(x.begin(), x.end()), x.end());
}
template <typename T, typename V>
int pos_l(const T& x, const V& v) {
  return lower_bound(x.begin(), x.end(), v) - x.begin();
}
template <typename T, typename V>
int pos_u(const T& x, const V& v) {
  return upper_bound(x.begin(), x.end(), v) - x.begin();
}
inline unsigned rand_g() {
  static mt19937 mt_rand((int)time(0));
  return mt_rand();
}
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using PII = pair<int, int>;
using VPII = vector<PII>;
}  // namespace Bigcat
using namespace Bigcat;
const LL base = LL(1e9 + 7);
const LL INFL = 1LL << 62;
const int INF = 1 << 30;
const int MAX = int(1e5 + 100);
const int MAX2 = MAX * 50;
int n, m, d;
VI gr[MAX];
VI stk;
int dfsn[MAX2];
int acc;
bool instk[MAX2];
int low[MAX2];
int color[MAX2];
int totColor;
void tarjan(int v) {
  low[v] = dfsn[v] = ++acc;
  stk.push_back(v);
  instk[v] = true;
  int nxd = (v % d + 1) % d;
  for (auto x : gr[v / d]) {
    int nx = x * d + nxd;
    if (dfsn[nx] == 0) {
      tarjan(nx);
      min_s(low[v], low[nx]);
    } else {
      if (instk[nx]) min_s(low[v], low[nx]);
    }
  }
  if (low[v] < dfsn[v]) return;
  while (true) {
    int t = stk.back();
    color[t] = totColor;
    stk.pop_back();
    instk[t] = false;
    if (t == v) break;
  }
  ++totColor;
}
string open[MAX];
vector<VI> ngr;
VI zs;
VI ss;
void solve1() {
  if (-1 > ngr.size()) {
    int x = 1;
  }
  LL result = 0;
  cin >> n >> m >> d;
  for (int i = 0; i < (int)(m); i++) {
    int u, v;
    cin >> u >> v;
    --u;
    --v;
    gr[u].push_back(v);
  }
  memset(color, -1, sizeof(color));
  tarjan(0);
  for (int i = 0; i < (int)(n); i++) {
    cin >> open[i];
  }
  ngr.resize(totColor + 1);
  zs.resize(totColor + 1);
  ss.assign(totColor + 1, 0);
  for (int i = 0; i < (int)(n); i++) {
    set<int> t;
    for (int j = 0; j < (int)(d); j++) {
      if (open[i][j] == '1') t.insert(color[i * d + j]);
    }
    for (auto x : t) {
      if (x >= 0) zs[x]++;
    }
  }
  for (int i = 0; i < (int)(n * d); i++) {
    int nxd = (i % d + 1) % d;
    int c = color[i];
    if (c < 0) continue;
    for (auto x : gr[i / d]) {
      int nx = x * d + nxd;
      int c1 = color[nx];
      if (c1 < 0) continue;
      if (c == c1) continue;
      ngr[c].push_back(c1);
    }
  }
  for (int i = 0; i < (int)(totColor); i++) {
    for (auto x : ngr[i]) {
      max_s(ss[i], ss[x]);
    }
    ss[i] += zs[i];
  }
  auto x = max_element(ss.begin(), ss.end());
  result = *x;
  cout << result << endl;
}
void solve() {
  int t = 1;
  for (int i = 0; i < t; ++i) {
    solve1();
  }
  int x = 1;
}
void io_init() {
  const int inId = 0;
  const int outId = 0;
  if (inId > 0) {
    cerr << "redirect stdin to input " << inId << endl;
    string s = "input";
    s += to_string(inId);
    s += ".txt";
    auto r = freopen(s.c_str(), "r", stdin);
    if (r == nullptr) {
      cerr << "invalid input file " << s << endl;
      ;
      r = freopen("CON", "r", stdin);
    }
  }
  if (outId > 0) {
    cerr << "redirect stdout to stdout " << outId << endl;
    string s = "stdout";
    s += to_string(outId);
    s += ".txt";
    auto r = freopen(s.c_str(), "w", stdout);
    if (r == nullptr) {
      cerr << "invalid output file " << s << endl;
      ;
      r = freopen("CON", "w", stdout);
    }
  }
}
int main(int argc, char* argv[]) {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout.precision(11);
  solve();
}
