import java.io.*;
import java.util.*;

public class palindromes_pk_wa1 {

	PrintWriter out;
	BufferedReader br;
	StringTokenizer st;

	String nextToken() throws IOException {
		while ((st == null) || (!st.hasMoreTokens()))
			st = new StringTokenizer(br.readLine());
		return st.nextToken();
	}

	public int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	public long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	public double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	public void solve() throws IOException {
		String s = nextToken();
		int k = nextInt();
		char[] a = new char[26];
		for (int i = 0; i < k; i++) {
			int x = nextToken().charAt(0) - 'a';
			char y = nextToken().charAt(0);
			a[x] = y;
		}
		
		ArrayList<Integer> ans = new ArrayList<Integer>();
		
		for (int i = 0; i < s.length() / 2 - 1; i++) {
			char x = s.charAt(i);
			char y = s.charAt(s.length() - i - 1);
			if (x == y)
				continue;
			if (a[x - 'a'] == y) {
				ans.add(i);
				continue;
			}
			
			if (a[y - 'a'] == x) {
				ans.add(s.length() - i - 1);
				continue;
			}
			
			if ((a[x - 'a'] == a[y - 'a']) && (a[x - 'a'] != 0)) {
				ans.add(i);
				ans.add(s.length() - i - 1);
				continue;
			}
			
			out.println("-1");
			return;
		}
		
		out.println(ans.size());
		for (int x : ans) {
			out.print((x + 1));
			if (x != ans.get(ans.size() - 1))
				out.print(' ');
		}
		out.println();
	}

	public void run() {
		try {
			br = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);

			br = new BufferedReader(new FileReader("palindromes.in"));
			out = new PrintWriter("palindromes.out");

			solve();

			out.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public static void main(String[] args) {
		new palindromes_pk_wa1().run();
	}
}
