#include <bits/stdc++.h>
using namespace std;
int qpow(int a, int p, int Mod) {
  int rt = 1;
  for (; p; p >>= 1, a = 1ll * a * a % Mod)
    if (p & 1) rt = 1ll * rt * a % Mod;
  return rt;
}
int rnd() {
  static unsigned seed = 142857, msk = (1u << 30) - 1;
  return (seed = seed * seed * 3 + seed * 2333 + 998244353) & msk;
}
class NTT {
 public:
  int Mod, d, Phi;
  int gn[25];
  void inc(int& x) {
    if (x >= Mod) x -= Mod;
  }
  void dec(int& x) {
    if (x < 0) x += Mod;
  }
  void init(int Mod) {
    this->Mod = Mod;
    d = 0, Phi = Mod - 1;
    while (!((Phi >> d) & 1)) d++;
    int r;
    while (qpow(r = rnd() % Phi + 1, Phi >> 1, Mod) == 1)
      ;
    gn[d - 1] = qpow(r, Phi >> d, Mod);
    for (int i = d - 1; i; i--) gn[i - 1] = 1ll * gn[i] * gn[i] % Mod;
  }
  void operator()(int* f) {
    int len = 1 << d;
    for (int i = 1, j = len >> 1, k; i < len - 1; i++, j += k) {
      if (i < j) swap(f[i], f[j]);
      for (k = len >> 1; j >= k; j -= k, k >>= 1)
        ;
    }
    int* wn = gn;
    for (int l = 2; l <= len; l <<= 1, wn++) {
      int hl = l >> 1;
      for (int i = 0; i < len; i += l) {
        int w = 1, a, b;
        for (int j = 0; j < hl; j++, w = 1ll * w * *wn % Mod) {
          a = f[i + j], b = 1ll * f[i + j + hl] * w % Mod;
          inc(f[i + j] = a + b);
          dec(f[i + j + hl] = a - b);
        }
      }
    }
  }
} NTT;
int n, m;
char s[100005];
int a[100005];
vector<int> f[25];
bool is_prime(int x) {
  for (int i = 2; i * i <= x; i++) {
    if (!(x % i)) {
      return false;
    }
  }
  return true;
}
int check(int Mod) {
  if (!is_prime(Mod)) return -1;
  NTT.init(Mod);
  int d = NTT.d;
  if (f[d].empty()) {
    f[d].resize(1 << d);
    int msk = (1 << d) - 1;
    for (int i = 0; i < n; i++) f[d][i & msk] += a[i];
  }
  vector<int> g = f[d];
  for (auto& x : g) {
    x %= Mod;
    (x < 0) && (x += Mod);
  }
  NTT(g.data());
  int wn = NTT.gn[d - 1], w = 1, L = 1 << d;
  for (int i = 0; i < L; i++, w = 1ll * w * wn % Mod) {
    if (w >= 2 && w <= Mod - 2 && !g[i]) {
      return w;
    }
  }
  return -1;
}
int main() {
  scanf("%d%d", &n, &m);
  scanf("%s", s);
  for (int i = 0; i < n; i++) a[i] += s[i];
  scanf("%s", s);
  for (int i = 0; i < n; i++) a[i] -= s[i];
  int ret;
  m = max(m, 5);
  while ((ret = check(m)) == -1) m++;
  printf("%d %d\n", m, ret);
  return 0;
}
