#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > occurr;
struct Node {
  int leaf;
  int link;
  int next[26];
  set<int> out;
  Node() {
    for (int i = 0; i < 26; ++i) {
      next[i] = 0;
    }
    leaf = link = 0;
  }
};
vector<Node> trie(1);
void insert(string &s, int id) {
  int node = 0;
  for (char ch : s) {
    if (!trie[node].next[ch - 'a']) {
      trie[node].next[ch - 'a'] = trie.size();
      trie.emplace_back();
    }
    node = trie[node].next[ch - 'a'];
  }
  trie[node].leaf = 1;
  trie[node].out.insert(id);
}
void build() {
  queue<int> q;
  for (int i = 0; i < 26; ++i) {
    if (trie[0].next[i]) {
      q.push(trie[0].next[i]);
    }
  }
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int ch = 0; ch < 26; ++ch) {
      int v = trie[u].next[ch];
      if (v) {
        q.push(v);
        int &link = trie[v].link;
        link = trie[u].link;
        while (link && trie[link].next[ch] == 0) {
          link = trie[link].link;
        }
        if (trie[link].next[ch]) {
          link = trie[link].next[ch];
        }
        if (trie[link].leaf) {
          trie[v].leaf |= 2;
          trie[v].out.insert(trie[link].out.begin(), trie[link].out.end());
        }
      } else {
        trie[u].next[ch] = trie[trie[u].link].next[ch];
      }
    }
  }
}
int n;
string text;
vector<int> matches;
void find_matches(int u, int idx) {
  if (idx == text.size()) return;
  int v = trie[u].next[text[idx] - 'a'];
  if (trie[v].leaf) {
    for (int i : trie[v].out) {
      occurr[i].emplace_back(idx);
    }
  }
  find_matches(v, idx + 1);
}
void print(string &txt) {
  for (int i = 0; i < txt.size(); ++i) {
    cout << setw(2) << i << ' ';
  }
  cout << '\n';
  for (char &c : txt) {
    cout << setw(2) << c << ' ';
  }
  cout << '\n';
}
int x, v[100123];
string s[100123];
int main() {
  cin >> text;
  cin >> n;
  occurr = vector<vector<int> >(n, vector<int>());
  for (int i = 0; i < n; ++i) {
    cin >> v[i] >> s[i];
    insert(s[i], i);
  }
  build();
  find_matches(0, 0);
  for (int i = 0; i < n; ++i) {
    if (occurr[i].size() < v[i]) {
      cout << "-1" << '\n';
    } else {
      int ans = text.size();
      if (v[i] == 1) {
        cout << s[i].size() << '\n';
        continue;
      }
      for (int j = v[i] - 1; j < occurr[i].size(); ++j) {
        ans =
            min(ans, occurr[i][j] - occurr[i][j - v[i] + 1] + (int)s[i].size());
      }
      cout << ans << '\n';
    }
  }
  return 0;
}
