//	#pragma comment(linker, "/STACK:60000000")
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <vector>
#include <set>
#include <string>

#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define len(x) (int((x).size()))
#ifdef LOCALD
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) {}
#endif

#ifdef __linux__
#define I64d "%lld"
#else
#define I64d "%I64d"
#endif

typedef long long int int64;
typedef long double ext;

const int inf = 1000000000;

const int maxs = 1000010;

using namespace std;

char s[maxs], text[maxs];
char t[2 * maxs];
int p[2 * maxs];

vector<int> ans[maxs];
int n, m, cnt;

void run(char *s, char *text, int id){
	//eprintf("%s#%s\n", s, text);
	int n = strlen(s);
	int m = strlen(text);
	for (int i = 0; i < n; i++)
		t[i] = s[i];
	t[n] = '#';
	for (int i = 0; i < m; i++)
		t[n + i + 1] = text[i];
	t[n + m + 1] = 0;
	p[0] = 0;
	//eprintf("0");
	for (int i = 1; i < n + m + 1; i++){		
		int j = p[i - 1];
		while ((j > 0) && (t[j] != t[i]))
			j = p[j - 1];
		if (t[j] == t[i])
			j++;
		p[i] = j;
		//eprintf(" %d", p[i]);
		if (p[i] == n){
			ans[id].pb(i - 2 * n + 1);
			cnt++;
		}
	}		
	//eprintf("\n");
}

int main()
{
    assert(freopen("inputik.txt", "rt", stdin));
    assert(freopen("outputik.txt", "wt", stdout));	
    scanf("%s\n", text);
	n = strlen(text);
	scanf("%d\n", &m);
	cnt = 0;
	for (int i = 0; i < m; i++){
		scanf("%s\n", s);
		run(s, text, i);	
	}    
	//eprintf("%d\n", cnt);
	for (int i = 0; i < m; i++){
		printf("%d", len(ans[i]));
		for (int j = 0; j < len(ans[i]); j++)
			printf(" %d", ans[i][j]);
		printf("\n");			
	}
    return 0;
}
