#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
    freopen("palindromes.in", "r", stdin);
    freopen("palindromes.out", "w", stdout);
    vector<int> ans;
    string s;
    cin >> s;
    int k;
    cin >> k;
    vector<pair<char, char> > rul(k);
    for (int i = 0; i < k; i++)
        cin >> rul[i].first >> rul[i].second;
    for (int i = 0; i < s.length() / 2; i++)
    {
        vector<int> olo;
        if (s[i] == s[s.length() - i - 1]) continue;
        bool f = false;
        for (int l = 0; l < k; l++)
            if (s[i] == rul[l].first && rul[l].second == s[s.length() - i - 1])
            {
                f = true;
                olo.push_back(i);
                break;
            }
        if (f)
        {
            ans.push_back(olo[0]);
            continue;
        }

        for (int l = 0; l < k; l++)
            if (s[s.length() - i - 1] == rul[l].first && s[i] == rul[l].second)
            {
                f = true;
                olo.push_back(s.length() - i - 1);
                break;
            }

        if (f)
        {
            ans.push_back(olo[0]);
            continue;
        }
        for (int j = 0; j < k; j++)
        {
            if (f) break;
            for (int l = 0; l < 26; l++)
                if (s[i] == rul[l].first && s[s.length() - i - 1] == rul[j].first &&
                    rul[j].second == rul[l].second)
                    {
                        f = true;
                        olo.push_back(i);
                        olo.push_back(s.length() - i - 1);
                        break;
                    }
        }
        if (f)
        {
            ans.push_back(olo[0]);
            ans.push_back(olo[1]); 
            }
        else 
        {
            cout << "-1";
            return 0;
        }
    }
    sort(ans.begin(), ans.end());
    cout << ans.size() << endl;
    for (int i = 0 ;  i < ans.size(); i++)
        cout << ans[i] + 1 <<  " ";
}