#include <bits/stdc++.h>
using namespace std;
const int MAXN = 400005;
struct node {
  int suff_link, par;
  char c;
  map<char, int> go;
  int is_word;
  node() {
    suff_link = -1, par = -1;
    is_word = 0;
  }
};
int n;
char s[MAXN];
vector<node> trie;
void trieInsert(const char *s) {
  int cur_node = 0;
  int len = strlen(s);
  for (int i = 0; i < len; i++) {
    int go = trie[cur_node].go[s[i]];
    if (go == 0) {
      node add;
      add.par = cur_node;
      add.c = s[i];
      trie.push_back(add);
      go = (int)trie.size() - 1;
      trie[cur_node].go[s[i]] = go;
    }
    cur_node = go;
  }
  trie[cur_node].is_word++;
}
int go(int cur_node, char c);
int getSuffLink(int cur_node) {
  if (trie[cur_node].suff_link != -1) return trie[cur_node].suff_link;
  if (trie[cur_node].par == 0) return trie[cur_node].suff_link = 0;
  char c = trie[cur_node].c;
  int parent = trie[cur_node].par;
  return trie[cur_node].suff_link = go(trie[parent].suff_link, c);
}
int go(int cur_node, char c) {
  if (trie[cur_node].go.count(c) > 0) return trie[cur_node].go[c];
  if (cur_node == 0) return trie[cur_node].go[c] = 0;
  int suff_link = getSuffLink(cur_node);
  return trie[cur_node].go[c] = go(suff_link, c);
}
void buildAhoCorasick() {
  queue<int> q;
  q.push(0);
  while (!q.empty()) {
    int cur_node = q.front();
    q.pop();
    for (map<char, int>::iterator it = trie[cur_node].go.begin();
         it != trie[cur_node].go.end(); it++) {
      q.push(it->second);
    }
    int suff_link = getSuffLink(cur_node);
    trie[cur_node].suff_link = suff_link;
    if (trie[suff_link].is_word)
      trie[cur_node].is_word += trie[suff_link].is_word;
  }
}
char str[MAXN];
int main() {
  scanf("%s", str);
  vector<string> wr;
  vector<int> pre;
  {
    node root;
    root.suff_link = 0;
    trie.push_back(root);
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
      scanf("%s", s);
      trieInsert(s);
      wr.push_back(s);
    }
    buildAhoCorasick();
    int cur_node = 0;
    int len = strlen(str);
    for (int i = 0; i < len; i++) {
      cur_node = go(cur_node, str[i]);
      pre.push_back(trie[cur_node].is_word);
    }
    trie.clear();
  }
  node root;
  root.suff_link = 0;
  trie.push_back(root);
  for (auto &s : wr) {
    reverse(s.begin(), s.end());
    trieInsert(s.c_str());
  }
  buildAhoCorasick();
  int cur_node = 0;
  int len = strlen(str);
  long long res = 0;
  long long last = 0;
  for (int i = len - 1; i >= 0; --i) {
    cur_node = go(cur_node, str[i]);
    long long x = trie[cur_node].is_word;
    res += pre[i] * last;
    last = x;
  }
  cout << res << endl;
  return 0;
}
