//	#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;


using namespace std;

const int maxs = 1000010;
const int alpha = 26;

char text[maxs], s[maxs];

struct vertex{
	int p, c, link, superlink, len;
	int go[alpha];
	vector<int> term;
};                                       
int vcnt, root;
vertex trie[maxs];

int mkvert(int p, int c, int len){
	trie[vcnt].p = p;
	trie[vcnt].c = c;
	trie[vcnt].len = len;
	trie[vcnt].superlink = trie[vcnt].link = -1;
	for (int i = 0; i < alpha; i++)
		trie[vcnt].go[i] = -1;
	trie[vcnt].term.clear();
	return vcnt++;		
}

void insert(char *s, int id){
	int v = root;
	for (int i = 0; s[i]; i++){
		int c = s[i] - 'a';
		if (trie[v].go[c] == -1)
			trie[v].go[c] = mkvert(v, c, i + 1);
		v = trie[v].go[c];			
	}
	trie[v].term.pb(id);
}

vector<int> ans[maxs];
int m;
int lq, rq;
int q[maxs];

void calc(int u){
	if (u == root){
		trie[u].link = -1;
		trie[u].superlink = root;
		for (int i = 0; i < alpha; i++)
			if (trie[u].go[i] == -1)
				trie[u].go[i] = root; 
		return;				
	}
	int p = trie[u].p, c = trie[u].c;
	if (trie[u].p == root)
		trie[u].link = root;
	else
		trie[u].link = trie[trie[p].link].go[c];
	int link = trie[u].link;
	trie[u].superlink = (len(trie[link].term) > 0) ? link : trie[link].superlink;	
	for (int i = 0; i < alpha; i++)
		if (trie[u].go[i] == -1)
			trie[u].go[i] = trie[trie[u].link].go[i];		
}

int main()
{
    //assert(freopen("inputik.txt", "rt", stdin));
    //assert(freopen("outputik.txt", "wt", stdout));
    scanf("%s\n", text);
    scanf("%d\n", &m);
    vcnt = 0;
	root = mkvert(-1, -1, 0);    

    for (int i = 0; i < m; i++){
    	scanf("%s", s);
    	insert(s, i);
    }
    //eprintf("BUILD\n");
    lq = 0;
    rq = 0;
    q[rq++] = root;
    while (lq < rq){
    	int u = q[lq++];
    	for (int i = 0; i < alpha; i++){
    		if (trie[u].go[i] != -1)
    			q[rq++] = trie[u].go[i];
    	}
    	calc(u);
    }
    //eprintf("CALC\n");
    int cnt = 0;
    int u = root;
    for (int i = 0; text[i]; i++){                                                     
    	int c = text[i] - 'a';                                                         
    	u = trie[u].go[c];
		int v = u;
		while (v != root){
			//eprintf("%d\n", v);
			for (int j = 0; j < len(trie[v].term); j++){      
				//eprintf("%d at %d\n", trie[v].term[j], i - trie[v].len + 1);
				ans[trie[v].term[j]].pb(i - trie[v].len + 2);				
				cnt++;
			}
			v = trie[v].superlink;
		}    			
    }
    //eprintf("ANS[%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;
}
