#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long INFF = 0x3f3f3f3f3f3f3f3fll;
const long long M = 1e9 + 7;
const long long maxn = 1e6 + 107;
const double pi = acos(-1.0);
const double eps = 0.0000000001;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
template <typename T>
inline void pr2(T x, int k = 64) {
  long long i;
  for (i = 0; i < k; i++) fprintf(stderr, "%d", (x >> i) & 1);
  putchar(' ');
}
template <typename T>
inline void add_(T &A, int B, long long MOD = M) {
  A += B;
  (A >= MOD) && (A -= MOD);
}
template <typename T>
inline void mul_(T &A, long long B, long long MOD = M) {
  A = (A * B) % MOD;
}
template <typename T>
inline void mod_(T &A, long long MOD = M) {
  A %= MOD;
  A += MOD;
  A %= MOD;
}
template <typename T>
inline void max_(T &A, T B) {
  (A < B) && (A = B);
}
template <typename T>
inline void min_(T &A, T B) {
  (A > B) && (A = B);
}
template <typename T>
inline T abs(T a) {
  return a > 0 ? a : -a;
}
inline long long powMM(long long a, long long b, long long mod = M) {
  long long ret = 1;
  for (; b; b >>= 1ll, a = a * a % mod)
    if (b & 1) ret = ret * a % mod;
  return ret;
}
int startTime;
void startTimer() { startTime = clock(); }
void printTimer() {
  fprintf(stderr, "/--- Time: %ld milliseconds ---/\n", clock() - startTime);
}
int MIN[1 << 20 | 7], MAX[1 << 20 | 7];
char s[27], t[27];
int pos[27], fin[27];
int c[maxn][2];
int main() {
  int n, i, m, k, j;
  scanf("%d%d%d", &n, &m, &k);
  scanf("%s%s", s + 1, t + 1);
  for (i = 1; i <= n; i++) scanf("%d%d", &c[i][0], &c[i][1]);
  for (i = 0; i < (1 << k); i++) MIN[i] = INF, MAX[i] = -INF;
  for (i = 1; i <= k; i++) pos[i] = i;
  for (i = n; i >= 1; i--) {
    int x = c[i][0], y = c[i][1];
    swap(pos[x], pos[y]);
  }
  for (i = 1; i <= n; i++) {
    int now, x = c[i][0], y = c[i][1];
    now = 0;
    for (j = 1; j <= k; j++) fin[pos[j]] = j;
    for (j = 1; j <= k; j++) now = (now << 1) | (s[fin[j]] - '0');
    min_(MIN[now], i);
    swap(pos[x], pos[y]);
    now = 0;
    for (j = 1; j <= k; j++) fin[pos[j]] = j;
    for (j = 1; j <= k; j++) now = (now << 1) | (t[fin[j]] - '0');
    max_(MAX[now], i);
  }
  int base = k;
  pair<int, pair<int, int> > ans = make_pair(0, make_pair(0, 0));
  for (i = 1; i <= k; i++) base -= (s[i] == '1') + (t[i] == '1');
  for (i = (1 << k) - 1; i >= 0; i--) {
    if (MAX[i] - MIN[i] + 1 >= m) {
      ans = max(ans, make_pair(base + __builtin_popcount(i) * 2,
                               make_pair(MIN[i], MAX[i])));
    }
    int t;
    for (t = 0; t < k; t++)
      if ((i >> t) & 1) {
        min_(MIN[i ^ (1 << t)], MIN[i]);
        max_(MAX[i ^ (1 << t)], MAX[i]);
      }
  }
  printf("%d\n", ans.first);
  printf("%d %d\n", ans.second.first, ans.second.second);
}
