#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7, N = 1e5 + 10;
long long h[N], siz[N], dp[N][10];
long long int power(long long a, long long b) {
  long long c = 1;
  for (; b; b /= 2) {
    if (b % 2) c = (c * a) % MOD;
    a = (a * a) % MOD;
  }
  return c;
}
long long int hsh(string s) {
  long long ans, k = 0;
  for (int i = s.size() - 1; i >= 0; i--, k++) {
    ans = (ans + (s[i] - '0') * power(101, k)) % MOD;
  }
  return ans;
}
int main() {
  string s;
  cin >> s;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    string s1;
    cin >> s1;
    h[i] = hsh(s1);
    siz[i] = s1.size();
  }
  for (int i = 0; i < n; i++) {
    if (s.size() >= siz[i]) {
      long long int ha = hsh(s.substr(0, siz[i]));
      if (ha == h[i]) dp[siz[i] - 1][i] = 1;
      for (int j = siz[i]; j < s.size(); j++) {
        ha = (ha - (s[j - siz[i]] - '0') * power(101, siz[i] - 1)) % MOD;
        if (ha < 0) ha += MOD;
        ha *= 101, ha += s[j] - '0', ha %= MOD;
        if (ha == h[i]) dp[j][i] = 1;
      }
    }
  }
  int r = 0, sum = 1, sizekol = 0, st = 0;
  for (int i = 0; i < s.size(); i++) {
    for (int j = 0; j < n; j++)
      if (dp[i][j])
        if (r <= sum - siz[j]) r = sum - (siz[j] - 1);
    if (sizekol < sum - r) st = r, sizekol = sum - r;
    sum++;
  }
  cout << sizekol << ' ' << st;
}
