#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
const long long N = 4e5 + 10;
const long long M = 3e8 + 1;
const long long big = 1e18;
const long long shift = 1000;
const long long hsh2 = 1964325029;
const long long mod = 998244353;
const long double EPS = 1e-14;
const long long block = 700;
string bb;
struct aho {
  long long t[N][26], p[N], k[N], b[N];
  long long c[N][26], tp[N], gl[N] = {0}, rt = 1, cur = 2;
  long long cnt[N] = {0}, sub[N] = {0};
  void add(string a) {
    long long v = rt;
    for (auto u : a) {
      long long c = u - 'a';
      if (!t[v][c])
        p[cur] = v, b[cur] = c, gl[cur] = gl[v] + 1, t[v][c] = cur++;
      v = t[v][c];
    }
    if (a != bb) cnt[v]++;
  }
  void sufsil(long long v) {
    k[v] = c[k[p[v]]][b[v]];
    if (k[v] == v) k[v] = rt;
    tp[v] = tp[k[v]];
    if (cnt[k[v]]) tp[v] = k[v];
    for (int j = 0; j < 26; j++) {
      c[v][j] = c[k[v]][j];
      if (t[v][j]) c[v][j] = t[v][j];
    }
  }
  void bldsuf() {
    k[1] = tp[1] = p[1] = 1;
    for (int i = 0; i < 26; i++) {
      c[1][i] = 1;
      if (t[1][i]) c[1][i] = t[1][i];
    }
    queue<int> q;
    q.push(rt);
    while (q.size()) {
      long long v = q.front();
      q.pop();
      for (int i = 0; i < 26; i++)
        if (t[v][i]) q.push(t[v][i]);
      if (v != 1) sufsil(v);
    }
  }
  string getstr(long long v) {
    string a;
    while (v != rt) a += (char)(b[v] + 'a'), v = p[v];
    reverse((a).begin(), (a).end());
    return a;
  }
  void get(string a) {
    long long v = 1;
    long long ans = 0;
    for (auto u : a) {
      v = t[v][u - 'a'];
      long long to = v;
      while (to != rt) {
        sub[gl[v]] += cnt[to];
        ans += sub[gl[v] - gl[to]] * cnt[to];
        to = tp[to];
      }
    }
    cout << ans << '\n';
  }
} rt;
long long t;
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> bb >> t;
  rt.add(bb);
  while (t--) {
    string a;
    cin >> a;
    rt.add(a);
  }
  rt.bldsuf();
  rt.get(bb);
}
