#include <iostream>
#include <sstream>

#include <vector>
#include <set>
#include <bitset>
#include <map>
#include <string>

#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <ctime>

#include <algorithm>
#include <numeric>
#include <deque>

#define foreach(i, x) for (__typeof((x).begin()) i = (x).begin(); i != (x).end(); ++i)
#define sqr(x) ((x) * (x))
#define len(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define pbk pop_back
#define mp make_pair
#define fs first
#define sc second
#define endl '\n'
#ifdef LOCALD
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) {}
#endif

#ifdef CUTEBMAING
#include "cutedebug.h"
#else
#define debug(x) ({})
#endif

using namespace std;

typedef long long int64;
typedef unsigned long long lint;
typedef long double ld;

const int inf = ((1 << 30) - 1);
const int64 linf = ((1ll << 62) - 1);
const int cmax = 1e+6 + 1;

char* s;
int n;
char* t[cmax];
int ln[cmax];

char* read(){
    static char _[cmax];
    assert(scanf("%s", _));
    int ln = strlen(_);
    char* result = new char[ln + 1];
    memcpy(result, _ , sizeof(char) * (ln + 1));
    return result;
}

struct node{
    map<char, node*> go;
    vector<int> term;
    node* link;
    inline node(): link(NULL){}
};

typedef node* pnode;

node* root;

inline void addString(char *s, int size, int index){
    node *cur = root;
    for (int i = 0; i < size; i++){
        if (!cur->go.count(s[i]))
            cur->go[s[i]] = new node();
        cur = cur->go[s[i]];
    }
    cur->term.pb(index);
}

void buildLinks(){
    static deque<pair<node*, pair<node*, char> > > q;
    q.pb(mp(root, mp(pnode(0), 0)));
    while (!q.empty()){
        node* v = q.begin()->fs, *p = q.begin()->sc.fs;
        char c = q.begin()->sc.sc;
        q.pop_front();
        node* cur = p ? p->link : NULL;
        while (cur != NULL && !cur->go.count(c))
            cur = cur->link;
        if (cur == NULL)
            v->link = v != root ? root : NULL;
        else
            v->link = cur->go[c];
        foreach(to, v->go)
            q.pb(mp(to->sc, mp(v, to->fs)));
    }
}

void buildTerm(){
    static deque<node*> q;
    q.pb(root);
    while (!q.empty()){
        node* v = *q.begin();
        q.pop_front();
        if (v->link != NULL){
            foreach(i, v->link->term)
                v->term.pb(*i);
        }
        foreach(to, v->go)
            q.pb(to->sc);
    }
}

vector<int> ans[cmax];

int main(){
    assert(freopen("inputik.txt", "r", stdin));
    assert(freopen("outputik.txt", "w", stdout));
    s = read();
    assert(scanf("%d", &n));
    for (int i = 0; i < n; i++){
        t[i] = read();
        ln[i] = strlen(t[i]);
    }
    root = new node();
    for (int i = 0; i < n; i++)
        addString(t[i], ln[i], i);
    buildLinks();
    buildTerm();
    node* cur = root;
    int size = strlen(s);
    int cnt = 0;
    for (int i = 0; i < size; i++){
        while (cur != root && !cur->go.count(s[i]))
            cur = cur->link;
        if (cur->go.count(s[i]))
            cur = cur->go[s[i]];
        foreach(j, cur->term){
            ans[*j].pb(i - ln[*j]);
            cnt++;
        }
    }
    //eprintf("%d\n", cnt);

    for (int i = 0; i < n; i++){
        int size = len(ans[i]);
        printf("%d", size);
        for (int j = 0; j < size; j++)
            printf(" %d", ans[i][j] + 2);		            
		printf("\n");            
    }
    return 0;
}
