#include <iostream>
#include <cstring>
#include <vector>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <cmath>
#include <ctime>
#include <string>
#include <cstdlib>
#include <algorithm>
using namespace std;
#define read            freopen("C:\\Users\\USER\\Desktop\\in.txt", "r", stdin)
#define write           freopen("C:\\Users\\USER\\Desktop\\in.txt", "a", stdout)
#define pii             pair<int, int>
#define pll             pair<LL, LL>
#define ff              first
#define ss              second
#define inf             1<<30
#define fin(i, a, n)    for (i=(a); i<(n); i++)
#define fid(i, n, a)    for (i=(n)-1; i>=(a); i--)
#define in(a)           scanf("%d", &a)
#define ins(a)          scanf("%s", a)
#define in2(a, b)       scanf("%d%d", &a, &b)
#define in3(a, b, c)    scanf("%d%d%d", &a, &b, &c)
#define pn              printf("\n");
#define pcs(a)          printf("Case %d: ", a)
#define pr(a)           printf("%d\n", a)
#define pr(a)           printf("%d\n", a)
#define prs(a)          printf("%d ", a)
#define pr2(a, b)       printf("%d %d\n", a, b)
#define pr3(a, b ,c)    printf("%d %d %d\n", a, b, c)
#define MP              make_pair
#define vi              vector<int>
#define vll             vector<LL>
#define msi             map<string, int>
#define mll             map<LL, LL>
#define _ceil(n, a)     (n)%(a)==0?(n)/(a):(n)/(a)+1;
#define cl              clear()
#define sz              size()
#define pb              push_back
#define MAX(A,B)        (((A)>(B))?(A):(B))
#define MIN(A,B)        (((A)<(B))?(A):(B))
#define all(X)          (X).begin(), (X).end ()
#define iter(it, X)     for (__typeof((X).begin()) it = (X).begin(); it != (X).end(); it++)
#define ext(a)          {printf("%s\n", a); return 0;}
typedef long long LL;
//int  dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int  dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int  dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//bool check(int n, int pos) {return (bool) (n & (1<<pos));}
//int  on(int n, int pos) {return n | (1<<pos);}
//int  off(int n, int pos) {return n & ~(1<<pos);}
//bool operator < (const data &d) const{return cost<d.cost;}

/* ***************************************************************************************
   *************************************************************************************** */
#define M 2010
int main()
{
#ifndef ONLINE_JUDGE
   // read;
#endif
    int n, m, k, i, j, cnt=0;
    vi p;
    in3(n, m, k);

    j=0;
    for (i=1; i<n+m+1; i++)
    {
        j++;
        if (j==n)
        {
            j=1;
            cnt++;
        }
        if (j==1) p.pb(i);
    }

for (i=0; i<k-1; i++)
{
    p.pb(1);
    p.pb(n+1);
}
sort(all(p));
j=n==m||k==1?p.sz:p.sz-1;
pr(j);
for (i=0; i<j; i++) prs(p[i]);
pn;

return 0;
}


#include <iostream>
#include <cstring>
#include <vector>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <cmath>
#include <ctime>
#include <string>
#include <cstdlib>
#include <algorithm>
using namespace std;
#define read            freopen("C:\\Users\\USER\\Desktop\\in.txt", "r", stdin)
#define write           freopen("C:\\Users\\USER\\Desktop\\in.txt", "a", stdout)
#define pii             pair<int, int>
#define pll             pair<LL, LL>
#define ff              first
#define ss              second
#define inf             1<<30
#define fin(i, a, n)    for (i=(a); i<(n); i++)
#define fid(i, n, a)    for (i=(n)-1; i>=(a); i--)
#define in(a)           scanf("%d", &a)
#define ins(a)          scanf("%s", a)
#define in2(a, b)       scanf("%d%d", &a, &b)
#define in3(a, b, c)    scanf("%d%d%d", &a, &b, &c)
#define pn              printf("\n");
#define pcs(a)          printf("Case %d: ", a)
#define pr(a)           printf("%d\n", a)
#define pr(a)           printf("%d\n", a)
#define prs(a)          printf("%d ", a)
#define pr2(a, b)       printf("%d %d\n", a, b)
#define pr3(a, b ,c)    printf("%d %d %d\n", a, b, c)
#define MP              make_pair
#define vi              vector<int>
#define vll             vector<LL>
#define msi             map<string, int>
#define mll             map<LL, LL>
#define _ceil(n, a)     (n)%(a)==0?(n)/(a):(n)/(a)+1;
#define cl              clear()
#define sz              size()
#define pb              push_back
#define MAX(A,B)        (((A)>(B))?(A):(B))
#define MIN(A,B)        (((A)<(B))?(A):(B))
#define all(X)          (X).begin(), (X).end ()
#define iter(it, X)     for (__typeof((X).begin()) it = (X).begin(); it != (X).end(); it++)
#define ext(a)          {printf("%s\n", a); return 0;}
typedef long long LL;
//int  dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int  dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int  dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//bool check(int n, int pos) {return (bool) (n & (1<<pos));}
//int  on(int n, int pos) {return n | (1<<pos);}
//int  off(int n, int pos) {return n & ~(1<<pos);}
//bool operator < (const data &d) const{return cost<d.cost;}

/* ***************************************************************************************
   *************************************************************************************** */
#define M 2010
int main()
{
#ifndef ONLINE_JUDGE
   // read;
#endif
    int n, m, k, i;
    in3(n, m, k);

    if (n==m)
    {
            n==2?pr(2*k+1):pr(2*k+2);

            for (i=0; i<k; i++) prs(1);
            prs(n);
            for (i=0; i<k-1; i++) prs(n+1);
            prs(n+m-1);
            if (n==2) prs(4);
            pn;
    }
    else
    {
        if (k==1)
        {
            if (m==1&&n>2)
            {
                pr(2);
                pr2(1, n);
            }
            else
            {
                pr(3);
                prs(1); prs(n);pr(n+m);
            }
        }
        else
        {
            pr(2*k);
            for (i=0; i<k; i++) prs(1);
            prs(n);
            for (i=0; i<k-1; i++) prs(n+1);
            pn;
        }
    }
return 0;
}


#include <iostream>
#include <cstring>
#include <vector>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <cmath>
#include <ctime>
#include <string>
#include <cstdlib>
#include <algorithm>
using namespace std;
#define read            freopen("C:\\Users\\USER\\Desktop\\in.txt", "r", stdin)
#define write           freopen("C:\\Users\\USER\\Desktop\\in.txt", "a", stdout)
#define pii             pair<int, int>
#define pll             pair<LL, LL>
#define ff              first
#define ss              second
#define inf             1<<30
#define fin(i, a, n)    for (i=(a); i<(n); i++)
#define fid(i, n, a)    for (i=(n)-1; i>=(a); i--)
#define in(a)           scanf("%d", &a)
#define ins(a)          scanf("%s", a)
#define in2(a, b)       scanf("%d%d", &a, &b)
#define in3(a, b, c)    scanf("%d%d%d", &a, &b, &c)
#define pn              printf("\n");
#define pcs(a)          printf("Case %d: ", a)
#define pr(a)           printf("%d\n", a)
#define pr(a)           printf("%d\n", a)
#define prs(a)          printf("%d ", a)
#define pr2(a, b)       printf("%d %d\n", a, b)
#define pr3(a, b ,c)    printf("%d %d %d\n", a, b, c)
#define MP              make_pair
#define vi              vector<int>
#define vll             vector<LL>
#define msi             map<string, int>
#define mll             map<LL, LL>
#define _ceil(n, a)     (n)%(a)==0?(n)/(a):(n)/(a)+1;
#define cl              clear()
#define sz              size()
#define pb              push_back
#define MAX(A,B)        (((A)>(B))?(A):(B))
#define MIN(A,B)        (((A)<(B))?(A):(B))
#define all(X)          (X).begin(), (X).end ()
#define iter(it, X)     for (__typeof((X).begin()) it = (X).begin(); it != (X).end(); it++)
#define ext(a)          {printf("%s\n", a); return 0;}
typedef long long LL;
//int  dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int  dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int  dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//bool check(int n, int pos) {return (bool) (n & (1<<pos));}
//int  on(int n, int pos) {return n | (1<<pos);}
//int  off(int n, int pos) {return n & ~(1<<pos);}
//bool operator < (const data &d) const{return cost<d.cost;}

/* ***************************************************************************************
   *************************************************************************************** */
#define M 2010
int main()
{
#ifndef ONLINE_JUDGE
   // read;
#endif
    int n, m, k, i;
    in3(n, m, k);

    if (n==m)
    {
            n==2&&k==1?pr(2*k+2):pr(2*k+1);

            for (i=0; i<k; i++) prs(1);
            prs(n);
            for (i=0; i<k-1; i++) prs(n+1);
            prs(n+m-1);
            if (n==2&&k==1) prs(4);
            pn;
    }
    else
    {
        if (k==1&&n-m==1)
        {
            if (m==1&&n>2)
            {
                pr(2);
                pr2(1, n);
            }
            else
            {
                pr(3);
                prs(1); prs(n);pr(n+m);
            }
        }
        else
        {
            pr(2*k);
            for (i=0; i<k; i++) prs(1);
            prs(n);
            for (i=0; i<k-1; i++) prs(n+1);
            pn;
        }
    }
return 0;
}


#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
using namespace std;

typedef long long LL;
typedef pair<int,int> PII;
typedef vector<int> VI;

#define PB push_back
#define MP make_pair
#define clr(a,b)    (memset(a,b,sizeof(a)))
#define rep(i,a)    for(int i=0; i<(int)a.size(); i++)

const int INF = 0x3f3f3f3f;
const double eps = 1E-8;

int n,m,k;

int main()
{
    scanf("%d%d%d",&n,&m,&k);
    if(n == m && n == 2)
    {
        printf("%d\n",k+2);
        for(int i=1; i<=k; i++)
            printf("1 ");
        printf("2 3\n");
        return 0;
    }
    else if(n ==m && n!=2)
    {
        printf("%d\n",k+2);
        for(int i=1; i<=k; i++)
            printf("1 ");
        printf("%d %d\n",n,n+2);
        return 0;
    }
    else if(n == m+1)
    {
        printf("%d\n",k+2);
        for(int i=1; i<=k; i++)
            printf("1 ");
        printf("%d %d\n",n,n+1);
    }
    else
    {
        if(n%m != 0)
        {
            printf("%d\n",k+2);
            for(int i=1; i<=k; i++)
                printf("1 ");
            printf("%d %d\n",m+1,n+1);
        }
        else
        {
            printf("%d\n",k+1);
            for(int i=1; i<=k; i++)
                printf("1 ");
            printf("%d\n",m+2);
        }
    }
    return 0;
}


#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
using namespace std;

typedef long long LL;
typedef pair<int,int> PII;
typedef vector<int> VI;

#define PB push_back
#define MP make_pair
#define clr(a,b)    (memset(a,b,sizeof(a)))
#define rep(i,a)    for(int i=0; i<(int)a.size(); i++)

const int INF = 0x3f3f3f3f;
const double eps = 1E-8;

int n,m,k;

int main()
{
    scanf("%d%d%d",&n,&m,&k);
    if(n == m && n == 2)
    {
        printf("%d\n",k+3);
        for(int i=1; i<=k; i++)
            printf("1 ");
        printf("2 3 4\n");
        return 0;
    }
    else if(n ==m && n!=2)
    {
        printf("%d\n",k+2);
        for(int i=1; i<=k; i++)
            printf("1 ");
        printf("%d %d\n",n,n+2);
        return 0;
    }
    else if(n == m+1)
    {
        printf("%d\n",k+2);
        for(int i=1; i<=k; i++)
            printf("1 ");
        printf("%d %d\n",n,n+1);
    }
    else
    {
        if(n%m != 0)
        {
            printf("%d\n",k+2);
            for(int i=1; i<=k; i++)
                printf("1 ");
            printf("%d %d\n",m+1,n+1);
        }
        else
        {
            printf("%d\n",k+1);
            for(int i=1; i<=k; i++)
                printf("1 ");
            printf("%d\n",m+2);
        }
    }
    return 0;
}


#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
using namespace std;

typedef long long LL;
typedef pair<int,int> PII;
typedef vector<int> VI;

#define PB push_back
#define MP make_pair
#define clr(a,b)    (memset(a,b,sizeof(a)))
#define rep(i,a)    for(int i=0; i<(int)a.size(); i++)

const int INF = 0x3f3f3f3f;
const double eps = 1E-8;

int n,m,k;

int main()
{
    scanf("%d%d%d",&n,&m,&k);
    if(n == m && n == 2)
    {
        printf("%d\n",k+2);
        for(int i=1; i<=k; i++)
            printf("1 ");
        printf("2 3\n");
        return 0;
    }

    if(n >= m+2)
    {
        printf("%d\n",k+1);
        for(int i=1; i<=k; i++)
            printf("1 ");
        printf("%d\n",n+1);
    }
    else
    {
        printf("%d\n",k+2);
        for(int i=1; i<=k; i++)
            printf("1 ");

        if(n == m+1)
            printf("%d %d\n",n,n+1);
        else
            printf("%d %d\n",n,n+2);
    }
    return 0;
}


#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
using namespace std;

typedef long long LL;
typedef pair<int,int> PII;
typedef vector<int> VI;

#define PB push_back
#define MP make_pair
#define clr(a,b)    (memset(a,b,sizeof(a)))
#define rep(i,a)    for(int i=0; i<(int)a.size(); i++)

const int INF = 0x3f3f3f3f;
const double eps = 1E-8;

int n,m,k;

int main()
{
    scanf("%d%d%d",&n,&m,&k);
    if(n >= m+2)
    {
        printf("%d\n",k*2);
        for(int i=1; i<=k; i++)
            printf("1 ");
        for(int i=1; i<=k; i++)
            printf("%d%c",n,i==k?'\n':' ');
    }
    else if(n == m+1)
    {
        printf("%d\n",k*2);
        for(int i=1; i<=k; i++)
            printf("1 ");
        for(int i=1; i<=k-1; i++)
            printf("%d ",n);
        printf("%d\n",n+1);
    }
    else
    {
        printf("%d\n",k*3);
        for(int i=1; i<=k; i++)
            printf("1 ");
        for(int i=1; i<=k; i++)
            printf("%d ",n);
        for(int i=1; i<=k; i++)
            printf("%d%c",2*n-1,i==k?'\n':' ');
    }

    return 0;
}


#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
using namespace std;

typedef long long LL;
typedef pair<int,int> PII;
typedef vector<int> VI;

#define PB push_back
#define MP make_pair
#define clr(a,b)    (memset(a,b,sizeof(a)))
#define rep(i,a)    for(int i=0; i<(int)a.size(); i++)

const int INF = 0x3f3f3f3f;
const double eps = 1E-8;

int n,m,k;

int main()
{
    scanf("%d%d%d",&n,&m,&k);
    if(n == m && n == 2)
    {
        printf("%d\n",k+2);
        for(int i=1; i<=k; i++)
            printf("1 ");
        printf("2 3\n");
        return 0;
    }
    else if(n ==m && n!=2)
    {
        printf("%d\n",k+2);
        for(int i=1; i<=k; i++)
            printf("1 ");
        printf("%d %d\n",n,n+2);
        return 0;
    }
    else if(n == m+1)
    {
        printf("%d\n",k+2);
        for(int i=1; i<=k; i++)
            printf("1 ");
        printf("%d %d\n",n,n+1);
    }
    else
    {
        printf("%d\n",k+2);
        for(int i=1; i<=k; i++)
            printf("1 ");
        printf("%d %d\n",m+1,n+1);
    }
    return 0;
}


#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
using namespace std;

typedef long long LL;
typedef pair<int,int> PII;
typedef vector<int> VI;

#define PB push_back
#define MP make_pair
#define clr(a,b)    (memset(a,b,sizeof(a)))
#define rep(i,a)    for(int i=0; i<(int)a.size(); i++)

const int INF = 0x3f3f3f3f;
const double eps = 1E-8;

int n,m,k;

int main()
{
    scanf("%d%d%d",&n,&m,&k);
    if(n ==m )
    {
        printf("%d\n",k*2+1);
        for(int i=1; i<=k; i++) printf("1 ");
        printf("%d ",n);
        for(int i=1; i<=k-1; i++)   printf("%d ",n+1);
        printf("%d ",n+2);
        return 0;
    }
    else if(n == m + 1)
    {
        printf("%d\n",k*2);
        for(int i=1; i<=k; i++) printf("1 ");
        printf("%d ",n);
        for(int i=1; i<=k-1; i++)   printf("%d ",n+1);

        return 0;
    }
    else
    {
        printf("%d\n",k*2);
        for(int i=1; i<=k; i++)
            printf("1 ");
        for(int i=1; i<=k; i++)
            printf("%d ",n);
        return 0;
    }
    return 0;
}


#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
using namespace std;

typedef long long LL;
typedef pair<int,int> PII;
typedef vector<int> VI;

#define PB push_back
#define MP make_pair
#define clr(a,b)    (memset(a,b,sizeof(a)))
#define rep(i,a)    for(int i=0; i<(int)a.size(); i++)

const int INF = 0x3f3f3f3f;
const double eps = 1E-8;

int n,m,k;

int main()
{
    scanf("%d%d%d",&n,&m,&k);
    if(n >= m+2)
    {
        printf("%d\n",k+1);
        for(int i=1; i<=k; i++)
            printf("1 ");
        printf("%d\n",n);
    }
    else
    {
        printf("%d\n",k+2);
        for(int i=1; i<=k; i++)
            printf("1 ");
        printf("%d %d\n",n,2*n-1);
    }
    return 0;
}


#include <stdio.h>
#include <string.h>
#include <vector>
#include <math.h>
#include <map>
#include <iostream>
#include <string>
#include <queue>
#include <stdlib.h>
#define clr(a,b) memset(a,b,sizeof(a))
using namespace std;

int n,m,k;

int main(){
    cin>>n>>m>>k;
    int tot=n+m,ans=1;
    if(k==1){
        ans=0;
        for(int i=1;i<=tot;i+=n-1)ans++;
        printf("%d\n",ans);
        printf("1");
        for(int i=n;i<=tot;i+=n-1)printf(" %d",i);puts("");
        return 0;
    }
    for(int i=1;;i+=n){
        if(i>1&&i-1<=tot)ans++;
        if(i>tot)break;
        ans+=k-1;
//        for(int j=1;j<k;j++)printf(" %d",i);
    }
    printf("%d\n1",ans);
    for(int i=1;;i+=n){
        if(i>1&&i-1<=tot)printf(" %d",i-1);
        if(i>tot)break;
        ans+=k-1;
        for(int j=1;j<k;j++)printf(" %d",i);
    }
//    if(tot%n==0){
//        ans++;printf(" %d\n",tot);
//    }
}


#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
using namespace std;

typedef long long LL;
typedef pair<int,int> PII;
typedef vector<int> VI;

#define PB push_back
#define MP make_pair
#define clr(a,b)    (memset(a,b,sizeof(a)))
#define rep(i,a)    for(int i=0; i<(int)a.size(); i++)

const int INF = 0x3f3f3f3f;
const double eps = 1E-8;

int n,m,k;

int main()
{
    scanf("%d%d%d",&n,&m,&k);
    if(n == m && n == 2)
    {
        printf("%d\n",k*4);
        for(int i=1; i<=k; i++) printf("1 ");
        for(int i=1; i<=k; i++) printf("2 ");
        for(int i=1; i<=k; i++) printf("3 ");
        for(int i=1; i<=k; i++) printf("4 ");
        return 0;
    }
    else if(n ==m && n!=2)
    {
        printf("%d\n",k*2+1);
        for(int i=1; i<=k; i++)
            printf("1 ");
        printf("%d ",n);
        for(int i=1; i<=k-1; i++)
            printf("%d ",n+1);
        printf("%d ",n+2);
        return 0;
    }
    else if(n == m + 1)
    {
        printf("%d\n",k*2);
        for(int i=1; i<=k; i++)
            printf("1 ");
        printf("%d ",n);
        for(int i=1; i<=k-1; i++)
            printf("%d ",n+1);

        return 0;
    }
    else
    {
        printf("%d\n",k*2);
        for(int i=1; i<=k; i++)
            printf("1 ");
        for(int i=1; i<=k; i++)
            printf("%d ",n);

        return 0;
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main(void) {
	ios_base::sync_with_stdio(false);

	int n, m, k;
	cin>>n>>m>>k;

	if(n == m) {
		int ans = k + 1 + k;
		cout<<ans<<"\n";
		for(int i = 0; i < k; ++i)
			cout<<"1 ";
		cout<<n<<" ";
		for(int i = 0; i < k-1; ++i)
			cout<<n+1<<" ";
		cout<<n+2<<" ";
	}
	else {
		int ans = 2*k;
		if(k == 1 && n == m+1) ans++;
		cout<<ans<<"\n";
		for(int i = 0; i < k; ++i)
			cout<<"1 ";
		cout<<n<<" ";
		for(int i = 0; i < k-1; ++i)
			cout<<n+1<<" ";
		if(k == 1 && n == m+1)	cout<<n+1<<" ";
	}

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main(void) {
	ios_base::sync_with_stdio(false);

	int n, m, k;
	cin>>n>>m>>k;

	vector<int> v, ans;
	for(int i = 0; i < k; ++i) {
		v.push_back(n);
		ans.push_back(1);
	}

	for(int i = 1; i < n+m; ++i) {
		int nv = 0;
		bool flag = true;
		if(i == n+m-1) {
			for(int j = 0; j < ans.size(); ++j) {
				if(v[j] > 1) {
					flag = false;
					break;
				}
			}
		}
		if(!flag)	break;
		for(int j = 0; j < ans.size(); ++j) {
			v[j]--;
			if(v[j] >= 1)	nv++;
		}
		if(nv == 0) {
			ans.push_back(i);
			v.push_back(n);
			--i;
		}
		else if(nv < k) {
			for(int j = 0; j < k-nv; ++j) {
				ans.push_back(i+1);
				v.push_back(n);
			}
		}
		if(i == n+m-1) {

		}
	}

	for(int i = 0; i < ans.size(); ++i)
		cout<<ans[i]<<" ";

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main(void) {
	ios_base::sync_with_stdio(false);

	int n, m, k;
	cin>>n>>m>>k;

	if(n == m) {
		int ans = k + k + k;
		for(int i = 0; i < k; ++i)
			cout<<"1 ";
		for(int i = 0; i < k; ++i)
			cout<<n<<" ";
		for(int i = 0; i < k; ++i)
			cout<<(2*n-1)<<" ";
	}
	else {
		int ans = 2*k;
		for(int i = 0; i < k; ++i)
			cout<<"1 ";
		for(int i = 0; i < k; ++i)
			cout<<n<<" ";
	}

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main(void) {
	ios_base::sync_with_stdio(false);

	int n, m, k;
	cin>>n>>m>>k;

	vector<int> v, ans;
	for(int i = 0; i < k; ++i) {
		v.push_back(n);
		ans.push_back(1);
	}

	for(int i = 1; i < n+m; ++i) {
		int nv = 0;
		bool flag = true;
		if(i == n+m-1) {
			for(int j = 0; j < ans.size(); ++j) {
				if(v[j] > 1) {
					flag = false;
					break;
				}
			}
		}
		if(!flag)	break;
		for(int j = 0; j < ans.size(); ++j) {
			v[j]--;
			if(v[j] >= 1)	nv++;
		}
		if(nv == 0) {
			ans.push_back(i);
			v.push_back(n);
			--i;
		}
		else if(nv < k) {
			for(int j = 0; j < k-nv; ++j) {
				ans.push_back(i+1);
				v.push_back(n);
			}
		}
		if(i == n+m-1) {

		}
	}
	cout<<(int)ans.size()<<"\n";
	for(int i = 0; i < ans.size(); ++i)
		cout<<ans[i]<<" ";

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main(void) {
	ios_base::sync_with_stdio(false);

	int n, m, k;
	cin>>n>>m>>k;

	if(n == m) {
		int ans = k + k + k;
		cout<<ans<<"\n";
		for(int i = 0; i < k; ++i)
			cout<<"1 ";
		for(int i = 0; i < k; ++i)
			cout<<n<<" ";
		for(int i = 0; i < k; ++i)
			cout<<(2*n-1)<<" ";
	}
	else {
		int ans = 2*k;
		cout<<ans<<"\n";
		for(int i = 0; i < k; ++i)
			cout<<"1 ";
		cout<<n<<" ";
		for(int i = 0; i < k-1; ++i)
			cout<<n+1<<" ";
	}

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main(void) {
	ios_base::sync_with_stdio(false);

	int n, m, k;
	cin>>n>>m>>k;

	if(n == m) {
		int ans = k + 1 + k;
		cout<<ans<<"\n";
		for(int i = 0; i < k; ++i)
			cout<<"1 ";
		cout<<n<<" ";
		for(int i = 0; i < k-1; ++i)
			cout<<n+1<<" ";
		cout<<n+2<<" ";
	}
	else {
		int ans = 2*k;
		if(k == 1) ans++;
		cout<<ans<<"\n";
		for(int i = 0; i < k; ++i)
			cout<<"1 ";
		cout<<n<<" ";
		for(int i = 0; i < k-1; ++i)
			cout<<n+1<<" ";
		if(k == 1)	cout<<n+1<<" ";
	}

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main(void) {
	ios_base::sync_with_stdio(false);

	int n, m, k;
	cin>>n>>m>>k;

	if(n == m) {
		int ans = k + 1 + k;
		cout<<ans<<"\n";
		for(int i = 0; i < k; ++i)
			cout<<"1 ";
		cout<<n<<" ";
		for(int i = 0; i < k-1; ++i)
			cout<<n+1<<" ";
		cout<<n+2<<" ";
	}
	else {
		int ans = 2*k;
		cout<<ans<<"\n";
		for(int i = 0; i < k; ++i)
			cout<<"1 ";
		cout<<n<<" ";
		for(int i = 0; i < k-1; ++i)
			cout<<n+1<<" ";
	}

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main(void) {
	ios_base::sync_with_stdio(false);

	int n, m, k;
	cin>>n>>m>>k;

	vector<int> v, ans;
	for(int i = 0; i < k; ++i) {
		v.push_back(n);
		ans.push_back(1);
	}

	for(int i = 1; i < n+m; ++i) {
		int nv = 0;
		for(int j = 0; j < ans.size(); ++j) {
			v[j]--;
			if(v[j] >= 1)	nv++;
		}
		if(nv == 0) {
			ans.push_back(i);
			v.push_back(n);
			--i;
		}
		else if(nv < k) {
			for(int j = 0; j < k-nv; ++j) {
				ans.push_back(i+1);
				v.push_back(n);
			}
		}
		bool flag = true;
		if(i == n+m-1) {
			for(int j = 0; j < ans.size(); ++j) {
				if(v[j] > 1) {
					flag = false;
					break;
				}
			}
			if(flag) {
				ans.push_back(n+m);
			}
		}
	}
	cout<<(int)ans.size()<<"\n";
	for(int i = 0; i < ans.size(); ++i)
		cout<<ans[i]<<" ";

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main(void) {
	ios_base::sync_with_stdio(false);

	int n, m, k;
	cin>>n>>m>>k;

	if(n == m) {
		int ans = k + k + k;
		cout<<ans<<"\n";
		for(int i = 0; i < k; ++i)
			cout<<"1 ";
		for(int i = 0; i < k; ++i)
			cout<<n<<" ";
		for(int i = 0; i < k; ++i)
			cout<<(2*n-1)<<" ";
	}
	else {
		int ans = 2*k;
		cout<<ans<<"\n";
		for(int i = 0; i < k; ++i)
			cout<<"1 ";
		for(int i = 0; i < k; ++i)
			cout<<n<<" ";
	}

	return 0;
}


#include<iostream>
#include<algorithm>

using namespace std;

long long ceil(long long num,long long den) {
    if(num%den==0)
        return num/den;
    return num/den+1;
}

void print(int a,int b) {
    cout<<a<<" "<<b<<"\n";
}

int main() {
    int t1,t2,x1,x2,t0;
    cin>>t1>>t2>>x1>>x2>>t0;
    if(t1==t0) {
        if(t1==t2)
            print(x1,x2);
        else
            print(x1,0);
        return 0;
    }
    if(t0==t2) {
        print(0,x2);
        return 0;
    }

    int y1=0,y2=x2;
    long long tn=t2,td=1;
    for(int x=1;x<=x1;x++) {
        long long y = ceil((t0-t1)*(long long)x,t2-t0);
        if(y>x2)
            continue;
        long long txn = (long long)t1*x+(long long)t2*y;
        long long txd = x+y;
        long long g = __gcd(txn,txd);
        txn/=g;
        txd/=g;
//        cout<<"# "<<x<<" "<<y<<" "<<tx<<endl;
        if(txn*td<txd*tn) {
            tn = txn;
            td = txd;
            y1 = x;
            y2 = y;
        }
        else if(txn*td==txd*tn)
            if(x+y>y1+y2) {
                y1 = x;
                y2 = y;
            }
    }
    print(y1,y2);
}


#include<iostream>
#include<vector>

using namespace std;

int main() {
    int n, m, k;
    cin>> n >> m >> k;
    vector<int> ans;
    for(int i=0; i<k; i++)
        ans.push_back(1);
    ans.push_back(n);
    for(int i=0; i<k-1; i++)
        ans.push_back(n+1);
    if(n==m)
        ans.push_back(2*n-1);
    cout<< ans.size() << "\n";
    cout<< ans[0];
    for(int i=1; i<ans.size(); i++)
        cout<< " " << ans[i];
    cout<< "\n";
}


#include<iostream>
#include<vector>

using namespace std;

int main() {
    int n, m, k;
    cin>> n >> m >> k;
    vector<int> ans;
    for(int i=0; i<k; i++)
        ans.push_back(1);
    ans.push_back(n);
    for(int i=0; i<k-1; i++)
        ans.push_back(n+1);
    if(n==m)
        ans.push_back(2*n-1);
    if(m==n-1 and k==1)
        ans.push_back(n+m);
    if(ans[ans.size()-1]+n-1<=n+m)
        ans.push_back(ans[ans.size()-1]+n-1);
    cout<< ans.size() << "\n";
    cout<< ans[0];
    for(int i=1; i<ans.size(); i++)
        cout<< " " << ans[i];
    cout<< "\n";
}


#include<iostream>
#include<vector>

using namespace std;

int main() {
    int n, m, k;
    cin>> n >> m >> k;
    vector<int> ans;
    for(int i=0; i<k; i++)
        ans.push_back(1);
    ans.push_back(n);
    for(int i=0; i<k-1; i++)
        ans.push_back(n+1);
    if(n==m)
        ans.push_back(2*n-1);
    if(m==n-1 and k==1)
        ans.push_back(n+m);
    cout<< ans.size() << "\n";
    cout<< ans[0];
    for(int i=1; i<ans.size(); i++)
        cout<< " " << ans[i];
    cout<< "\n";
}


#include<iostream>
#include<vector>

using namespace std;

int main() {
    int n, m, k;
    cin>> n >> m >> k;
    vector<int> ans;
    for(int i=0; i<k; i++)
        ans.push_back(1);
    ans.push_back(n);
    for(int i=0; i<k-1; i++)
        ans.push_back(n+1);
    if(n==m) {
        if(k==1)
            ans.push_back(2*n-1);
        else
            ans.push_back(2*n);
    }
    if(m==n-1 and k==1)
        ans.push_back(n+m);
    if(ans[ans.size()-1]+n-1<=n+m)
        ans.push_back(ans[ans.size()-1]+n-1);
    cout<< ans.size() << "\n";
    cout<< ans[0];
    for(int i=1; i<ans.size(); i++)
        cout<< " " << ans[i];
    cout<< "\n";
}


#include <iostream>
//#include <vector>

using namespace std;;

int main()
{
    int n, m, k, ans;
    cin>> n>> m>> k;
    if(n == m)
    {
        cout<<2*k+1<<endl;
        for(int i=0; i<k; i++)
            cout<<"1 ";
        cout<<n<<" ";
        for(int i=0; i<k-1;i++)
            cout<<n+1<<" ";
        cout<<2*n-1<<" ";
    }
    else
    {
        cout<<2*k<<endl;
        for(int i=0; i<k; i++)
            cout<<"1 ";
        cout<<n<<" ";
        for(int i=0; i<k-1; i++)
            cout<<n+1<<" ";
    }
    //cin>>n;
    return 0;
}


#include <iostream>
#include <vector>

using namespace std;;

int main()
{
    int n, m, k, ans;
    cin>> n>> m>> k;
    if(n == m)
    {
        cout<<2*k+1<<endl;
        for(int i=0; i<k; i++)
            cout<<"1 ";
        cout<<n<<" ";
        for(int i=0; i<k-1;i++)
            cout<<n+1<<" ";
        cout<<2*n-1<<" ";
    }
    else
    {
        cout<<2*k<<endl;
        for(int i=0; i<k; i++)
            cout<<"1 ";
        cout<<n<<" ";
        for(int i=0; i<k-1; i++)
            cout<<n+1<<" ";
    }
    //cin>>n;
    return 0;
}


#include <iostream>
#include <vector>

using namespace std;;

int main()
{
    int n, m, k, ans;
    cin>> n>> m>> k;
    if(n == m)
    {

        cout<<2*k+1<<endl;
        if(k == 1 )
        {
            cout<<"1 "<<n<<" "<<2*n-1;
        }
        else
        {
            for(int i=0; i<k; i++)
                cout<<"1 ";
            cout<<n<<" ";
            for(int i=0; i<k-1;i++)
                cout<<n+1<<" ";
            cout<<2*n<<" ";
        }
    }
    else
    {
        if(k == 1 && n-m == 1)
        {
            cout<<"3"<<endl;
            cout<<"1 "<<n<<" "<<n+1<<endl;
        }
        else
        {
            cout<<2*k<<endl;
            for(int i=0; i<k; i++)
                cout<<"1 ";
            cout<<n<<" ";
            for(int i=0; i<k-1; i++)
                cout<<n+1<<" ";
        }
    }
   // cin>>n;
    return 0;
}


#include <iostream>
#include <vector>

using namespace std;;

int main()
{
    int n, m, k, ans;
    cin>> n>> m>> k;
    if(n == m)
    {

        cout<<2*k+1<<endl;
        if(k == 1)
        {
            cout<<"1 "<<n<<" "<<2*n-1;
        }
        else
        {
            for(int i=0; i<k; i++)
                cout<<"1 ";
            cout<<n<<" ";
            for(int i=0; i<k-1;i++)
                cout<<n+1<<" ";
            cout<<2*n<<" ";
        }
    }
    else
    {
        cout<<2*k<<endl;
        for(int i=0; i<k; i++)
            cout<<"1 ";
        cout<<n<<" ";
        for(int i=0; i<k-1; i++)
            cout<<n+1<<" ";
    }
    //cin>>n;
    return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<vector>
#include<algorithm>
using namespace std;

int a[10000];
int i,j,n,m,k;

int main(){
//    freopen("e:\\in.txt","r",stdin);
    scanf("%d%d%d",&n,&m,&k);
    a[1]=k;
    int num=k;
    for(i=2;i<=n+m;i++){
//        if(i==3)
//        puts("");
        num-=(i-n>=1)?a[i-n]:0;
        if((num-(i-n+1>=1)?a[i-n+1]:0)<1) a[i]++;
        if(num+a[i]<=k){
            a[i]+=(k-num-a[i]);
        }
        num+=a[i];
    }
    int ans=0;
    for(i=1;i<=n+m;i++) ans+=a[i];
    printf("%d\n",ans);
    for(i=1;i<=n+m;i++){
        for(int j=1;j<=a[i];j++)
            printf("%d ",i);
    }
    return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<vector>
#include<algorithm>
using namespace std;

int a[10000];
int i,j,n,m,k;

int main(){
//    freopen("e:\\in.txt","r",stdin);
    scanf("%d%d%d",&n,&m,&k);
    a[1]=k;
    int num=k;
    for(i=2;i<=n+m;i++){
        if(i==10)
        puts("");
        num-=(i-n>=1)?a[i-n]:0;
        if(num-a[i-n+1]<1) a[i]++;
        if(num+a[i]<=k){
            a[i]+=(k-num-a[i]);
        }
        num+=a[i];
    }
    int ans=0;
    for(i=1;i<=n+m;i++) ans+=a[i];
    printf("%d\n",ans);
    for(i=1;i<=n+m;i++){
        for(int j=1;j<=a[i];j++)
            printf("%d ",i);
    }
    return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<vector>
#include<algorithm>
using namespace std;

int a[10000];
int i,j,n,m,k;

int main(){
//    freopen("e:\\in.txt","r",stdin);
    scanf("%d%d%d",&n,&m,&k);
    a[1]=k;
    int num=k;
    for(i=2;i<=n+m;i++){
        if(num-a[i-n+1]<1) a[i]++;
        num-=(i-n>=1)?a[i-n]:0;
        if(num+a[i]<=k){
            a[i]+=k-num;
        }
        num+=a[i];
    }
    int ans=0;
    for(i=1;i<=n+m;i++) ans+=a[i];
    printf("%d\n",ans);
    for(i=1;i<=n+m;i++){
        for(int j=1;j<=a[i];j++)
            printf("%d ",i);
    }
    return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<vector>
#include<algorithm>
using namespace std;

int a[10000];
int i,j,n,m,k;

int main(){
//    freopen("e:\\in.txt","r",stdin);
    scanf("%d%d%d",&n,&m,&k);
    a[1]=k;
    int num=k;
    for(i=2;i<=n+m;i++){
        if(i==2)
        puts("");
        num-=(i-n>=1)?a[i-n]:0;
        if((num-((i-n+1>=1)?a[i-n+1]:0))<1) a[i]++;
        if(num+a[i]<=k){
            a[i]+=(k-num-a[i]);
        }
        num+=a[i];
    }
    int ans=0;
    for(i=1;i<=n+m;i++) ans+=a[i];
    printf("%d\n",ans);
    for(i=1;i<=n+m;i++){
        for(int j=1;j<=a[i];j++)
            printf("%d ",i);
    }
    return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<vector>
#include<algorithm>
using namespace std;

int a[10000];
int i,j,n,m,k;

int main(){
//    freopen("e:\\in.txt","r",stdin);
    scanf("%d%d%d",&n,&m,&k);
    a[1]=k;
    int num=k;
    for(i=2;i<=n+m;i++){
        num-=(i-n>=1)?a[i-n]:0;
        if(num-a[i-n+1]<1) a[i]++;
        if(num+a[i]<=k){
            a[i]+=k-num;
        }
        num+=a[i];
    }
    int ans=0;
    for(i=1;i<=n+m;i++) ans+=a[i];
    printf("%d\n",ans);
    for(i=1;i<=n+m;i++){
        for(int j=1;j<=a[i];j++)
            printf("%d ",i);
    }
    return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<vector>
#include<algorithm>
using namespace std;

int a[10000];
int i,j,n,m,k;

int main(){
//    freopen("e:\\in.txt","r",stdin);
    scanf("%d%d%d",&n,&m,&k);
    a[1]=k;
    int num=k;
    for(i=2;i<=n+m;i++){
        if(num-a[i-n+1]<1) a[i]++;
        num-=(i-n>=1)?a[i-n]:0;
        if(num+a[i]<=k){
            a[i]+=k-num;
        }
        num+=a[i];
    }
    for(i=1;i<=n+m;i++){
        for(int j=1;j<=a[i];j++)
            printf("%d ",i);
    }
    return 0;
}


#include<iostream>
#include <stdio.h>
#include<memory.h>
using namespace std;
#define rep(i,n,r) for(int i=(n);i<(r);i++)
#define rev(i,n,r) for(int i=(n);i>=(r);i--)
#define mem(a) memset(a,0,sizeof(a))
typedef long long LL;
int main()
{
    int a,b,c;
    while(scanf("%d%d%d",&a,&b,&c)!=EOF)
    {
        int l;
        if(c!=1)
        {
            l=(a+b)/a*c;
            if(!((a+b)%a))
                l++;
            else
                l+=c;
        }
        else
            l=(a+b)/(a-1)+1;
        printf("%d\n",l);
        rep(i,0,c)
        {
            if(i)
                printf(" ");
            printf("1");
        }
        l-=c;
        int n=a;
        while(l)
        {
            printf(" %d",n);
            l--;
            if(l)
            {
                rep(i,0,c-1)
                    printf(" %d",n+1);
                if(c-1)
                    n+=a;
                else
                    n+=a-1;
                l-=c-1;
            }
        }
        printf("\n");
    }
    return 0;
}


#include<iostream>
#include <stdio.h>
#include<memory.h>
using namespace std;
#define rep(i,n,r) for(int i=(n);i<(r);i++)
#define rev(i,n,r) for(int i=(n);i>=(r);i--)
#define mem(a) memset(a,0,sizeof(a))

int main()
{
    int a,b,c;
    while(scanf("%d%d%d",&a,&b,&c)!=EOF)
    {
        int l=(a+b)/a*c;
        if(!((a+b)/c))
            l++;
        else
            l+=c;
        printf("%d\n",l);
        rep(i,0,c)
        {
            if(i)
                printf(" ");
            printf("1");
        }
        l-=c;
        int n=a;
        while(l)
        {
            printf(" %d",n);
            n++;
            l--;
            if(l)
            {
                rep(i,0,c-1)
                    printf(" %d",n);
                if(c-1)
                    n+=a-1;
                else
                    n+=a-2;
                l-=c-1;
            }
        }
        printf("\n");
    }
    return 0;
}


#include<iostream>
#include <stdio.h>
#include<memory.h>
using namespace std;
#define rep(i,n,r) for(int i=(n);i<(r);i++)
#define rev(i,n,r) for(int i=(n);i>=(r);i--)
#define mem(a) memset(a,0,sizeof(a))
typedef long long LL;
int main()
{
    LL a,b,c;
    while(scanf("%lld%lld%lld",&a,&b,&c)!=EOF)
    {
        LL l=(a+b)/a*c;
        if(!((a+b)%a))
            l++;
        else
            l+=c;
        printf("%d\n",l);
        rep(i,0,c)
        {
            if(i)
                printf(" ");
            printf("1");
        }
        l-=c;
        LL n=a;
        while(l)
        {
            printf(" %lld",n);
            l--;
            if(l)
            {
                rep(i,0,c-1)
                    printf(" %lld",n+1);
                if(c-1)
                    n+=a;
                else
                    n+=a-1;
                l-=c-1;
            }
        }
        printf("\n");
    }
    return 0;
}


#include<iostream>
#include <stdio.h>
#include<memory.h>
using namespace std;
#define rep(i,n,r) for(int i=(n);i<(r);i++)
#define rev(i,n,r) for(int i=(n);i>=(r);i--)
#define mem(a) memset(a,0,sizeof(a))

int main()
{
    int a,b,c;
    while(scanf("%d%d%d",&a,&b,&c)!=EOF)
    {
        int l=(a+b)/a*c;
        if(!((a+b)%a))
            l++;
        else
            l+=c;
        printf("%d\n",l);
        rep(i,0,c)
        {
            if(i)
                printf(" ");
            printf("1");
        }
        l-=c;
        int n=a;
        while(l)
        {
            printf(" %d",n);
            n++;
            l--;
            if(l)
            {
                rep(i,0,c-1)
                    printf(" %d",n);
                if(c-1)
                    n+=a-1;
                else
                    n+=a-2;
                l-=c-1;
            }
        }
        printf("\n");
    }
    return 0;
}


#include<iostream>
#include <stdio.h>
#include<memory.h>
using namespace std;
#define rep(i,n,r) for(int i=(n);i<(r);i++)
#define rev(i,n,r) for(int i=(n);i>=(r);i--)
#define mem(a) memset(a,0,sizeof(a))
typedef long long LL;
int main()
{
    int a,b,c;
    while(scanf("%d%d%d",&a,&b,&c)!=EOF)
    {
        int l=(a+b)/a*c;
        if(!((a+b)%a))
            l++;
        else
            l+=c;
        printf("%d\n",l);
        rep(i,0,c)
        {
            if(i)
                printf(" ");
            printf("1");
        }
        l-=c;
        int n=a;
        while(l)
        {
            printf(" %d",n);
            l--;
            if(l)
            {
                rep(i,0,c-1)
                    printf(" %d",n+1);
                if(c-1)
                    n+=a;
                else
                    n+=a-1;
                l-=c-1;
            }
        }
        printf("\n");
    }
    return 0;
}


#include<iostream>
#include <stdio.h>
#include<memory.h>
using namespace std;
#define rep(i,n,r) for(int i=(n);i<(r);i++)
#define rev(i,n,r) for(int i=(n);i>=(r);i--)
#define mem(a) memset(a,0,sizeof(a))
typedef long long LL;
int main()
{
    int a,b,c;
    while(scanf("%d%d%d",&a,&b,&c)!=EOF)
    {
        int l;
        if(c!=1)
        {
            l=(a+b)/a*c;
            if(!((a+b)%a))
                l++;
            else
                l+=c;
        }
        else
            l=(a+b-1)/(a-1)+1;
        printf("%d\n",l);
        rep(i,0,c)
        {
            if(i)
                printf(" ");
            printf("1");
        }
        l-=c;
        int n=a;
        while(l)
        {
            printf(" %d",n);
            l--;
            if(l)
            {
                rep(i,0,c-1)
                    printf(" %d",n+1);
                if(c-1)
                    n+=a;
                else
                    n+=a-1;
                l-=c-1;
            }
        }
        printf("\n");
    }
    return 0;
}


#include <iostream>
#include <stdio.h>
using namespace std;
    int n, m, k, ret, ans[1111111];
    bool mark[2*1111];
int main(){
    scanf("%d%d%d", &n, &m, &k);
    if(k==1){
        ret = (n+m-1+n-2)/(n-1);
        cout << ret << endl;
        for(int i = 1, j = 1; j<= ret; j++, i+=n-1)cout << i <<" ";
        cout << endl;
        return 0;
    }
    fill(mark, mark+n+m, false);
    mark[1] = true;
    int i = n;
    ret = 0;
    for(int i= 1; i <= k; i++)ans[++ret] = 1;
    for(int i= 1; i <= n; i++)mark[i] = true;
    if(m==1)ans[++ret] = n;
    else
    while(i<n+m-1){
        mark[i] = true;
        ans[++ret] = i;
        if(mark[(i+1)%(n+m-1)])break;
        for(int j = 1; j < k; j++)ans[++ret] = i+1;
        for(int j = i+1; j < i+1+n; j++)mark[j%(n+m-1)] = true;
        i = (i+n);
    }
    cout << ret << endl;
    for(int i = 1; i <= ret;i++)cout << ans[i]<<" ";
    cout << endl;
    return 0;
}


#include <iostream>
#include <stdio.h>
using namespace std;
    int n, m, k, ret, ans[1111111];
    bool mark[2*1111];
int main(){
    scanf("%d%d%d", &n, &m, &k);
    if(k==1){
        ret = (n+m+n-2)/(n-1);
        cout << ret << endl;
        for(int i = 1, j = 1; j<= ret; j++, i+=n-1)cout << i <<" ";
        cout << endl;
        return 0;
    }
    fill(mark, mark+n+m, false);
    mark[1] = true;
    int i = n;
    ret = 0;
    for(int i= 1; i <= k; i++)ans[++ret] = 1;
    for(int i= 1; i <= n; i++)mark[i] = true;
    if(m==1)ans[++ret] = n;
    else
    while(i<=n+m){
        mark[i] = true;
        ans[++ret] = i;
        int p = (i+1)%(n+m);
        if(p==0)p = (n+m);
        if(mark[p])break;
        for(int j = 1; j < k; j++)ans[++ret] = i+1;
        for(int j = i+1; j < i+1+n; j++){
            p = j%(n+m);
            if(p==0)p = n+m;
            mark[p] = true;
        }
        i = (i+n-1);
    }
    cout << ret << endl;
    for(int i = 1; i <= ret;i++)printf("%d ", ans[i]);
    return 0;
}


#include <iostream>
#include <stdio.h>
using namespace std;
    int n, m, k, ret, ans[1111111];
    bool mark[2*1111];
int main(){
    scanf("%d%d%d", &n, &m, &k);
    if(k==1){
        ret = (n+m-1+n-2)/(n-1);
        cout << ret << endl;
        for(int i = 1, j = 1; j<= ret; j++, i+=n-1)cout << i <<" ";
        cout << endl;
        return 0;
    }
    fill(mark, mark+n+m, false);
    mark[1] = true;
    int i = n;
    ret = 0;
    for(int i= 1; i <= k; i++)ans[++ret] = 1;
    for(int i= 1; i <= n; i++)mark[i] = true;
    if(m==1)ans[++ret] = n;
    else
    while(i<=n+m-1){
        mark[i] = true;
        ans[++ret] = i;
        int p = (i+1)%(n+m-1);
        if(p==0)p = (n+m-1);
        if(mark[p])break;
        for(int j = 1; j < k; j++)ans[++ret] = i+1;
        for(int j = i+1; j < i+1+n; j++){
            p = j%(n+m-1);
            if(p==0)p = n+m-1;
            mark[p] = true;
        }
        i = (i+n);
    }
    cout << ret << endl;
    for(int i = 1; i <= ret;i++)printf("%d ", ans[i]);
    return 0;
}


#include <iostream>
#include <stdio.h>
using namespace std;
    int n, m, k, ret, ans[1111111];
    bool mark[2*1111];
int main(){
    scanf("%d%d%d", &n, &m, &k);
    if(k==1){
        ret = (n+m+n-2)/(n-1);
        cout << ret << endl;
        for(int i = 1, j = 1; j<= ret; j++, i+=n-1)cout << i <<" ";
        cout << endl;
        return 0;
    }
    fill(mark, mark+n+m, false);
    mark[1] = true;
    int i = n;
    ret = 0;
    for(int i= 1; i <= k; i++)ans[++ret] = 1;
    for(int i= 1; i <= n; i++)mark[i] = true;
    while(i<=n+m){
        mark[i] = true;
        ans[++ret] = i;
        int p = (i+1)%(n+m);
        if(p==0)p = (n+m);
        if(mark[p])break;
        for(int j = 1; j < k; j++)ans[++ret] = i+1;
        for(int j = i+1; j < i+1+n; j++){
            p = j%(n+m);
            if(p==0)p = n+m;
            mark[p] = true;
        }
        i = (i+n);
    }
    cout << ret << endl;
    for(int i = 1; i <= ret;i++)printf("%d ", ans[i]);
    return 0;
}


#include <iostream>
#include <stdio.h>
using namespace std;
    int n, m, k, ret, ans[1111111];
    bool mark[2*1111];
int main(){
    scanf("%d%d%d", &n, &m, &k);
    if(k==1){
        ret = (n+m-1+n-2)/(n-1);
        cout << ret << endl;
        for(int i = 1, j = 1; j<= ret; j++, i+=n-1)cout << i <<" ";
        cout << endl;
        return 0;
    }
    fill(mark, mark+n+m, false);
    mark[1] = true;
    int i = n;
    ret = 0;
    for(int i= 1; i <= k; i++)ans[++ret] = 1;
    for(int i= 1; i <= n; i++)mark[i] = true;
    if(m==1)ans[++ret] = n;
    else
    while(i<=n+m-1){
        mark[i] = true;
        ans[++ret] = i;
        int p = (i+1)%(n+m-1);
        if(p==0)p = (n+m-1);
        if(mark[p])break;
        for(int j = 1; j < k; j++)ans[++ret] = i+1;
        for(int j = i+1; j < i+1+n; j++){
            p = j%(n+m-1);
            if(p==0)p = n+m-1;
            mark[p] = true;
        }
        i = (i+n);
    }
    cout << ret << endl;
    for(int i = 1; i <= ret;i++)cout << ans[i]<<" ";
    cout << endl;
    return 0;
}


#include <iostream>
#include <stdio.h>
using namespace std;
    int n, m, k, ret, ans[1111111];
    bool mark[2*1111];
int main(){
    scanf("%d%d%d", &n, &m, &k);
    if(k==1){
        ret = (n+m-1+n-2)/(n-1);
        cout << ret << endl;
        for(int i = 1, j = 1; j<= ret; j++, i+=n-1)cout << i <<" ";
        cout << endl;
        return 0;
    }
    fill(mark, mark+n+m, false);
    mark[1] = true;
    int i = n;
    ret = 0;
    for(int i= 1; i <= k; i++)ans[++ret] = 1;
    for(int i= 1; i <= n; i++)mark[i] = true;
    if(m==1)ans[++ret] = n;
    else
    while(i<=n+m-1){
        mark[i] = true;
        ans[++ret] = i;
        int p = (i+1)%(n+m-1);
        if(p==0)p = (n+m-1);
        if(mark[p])break;
        for(int j = 1; j < k; j++)ans[++ret] = i+1;
        for(int j = i+1; j < i+1+n; j++){
            p = j%(n+m-1);
            if(p==0)p = n+m-1;
            mark[p] = true;
        }
        i = (i+n-1);
    }
    cout << ret << endl;
    for(int i = 1; i <= ret;i++)printf("%d ", ans[i]);
    return 0;
}


#include <iostream>
#include <cstring>
using namespace std;

int main()
{
    int n,m,k;
    int i,sta[1010],nans=0,ans[1010];
    memset(sta,0,sizeof(sta));
    cin >> n >> m >> k;
    for(i=1;i<=k;i++)
        ans[++nans]=1;
    ans[++nans]=n;
    if(k>1)
        for(i=2;i<=k;i++)
            ans[++nans]=n+1;
    if(2*n<=n+m)
        if(k==1)
            ans[++nans]=n+m-1;
        else
            ans[++nans]=n+m;
    if(k==1&&2*n==n+m+1)
        ans[++nans]=n+1;
    cout << nans << endl;
    for(i=1;i<=nans;i++)
        cout << ans[i] << ' ';
    cout << endl;
    return 0;
}


#include <iostream>
#include <cstring>
using namespace std;

int main()
{
    int n,m,k;
    int i,sta[1010],nans=0,ans[1010];
    memset(sta,0,sizeof(sta));
    cin >> n >> m >> k;
    for(i=1;i<=k;i++)
        ans[++nans]=1;
    ans[++nans]=n;
    if(k>1)
        for(i=2;i<=k;i++)
            ans[++nans]=n+1;
    if(2*n<=n+m)
        if(k==1)
            ans[++nans]=n+m-1;
        else
            ans[++nans]=n+m;
    cout << nans << endl;
    for(i=1;i<=nans;i++)
        cout << ans[i] << ' ';
    cout << endl;
    return 0;
}


#include <iostream>
#include <cstring>
using namespace std;

int sta[100000],ans[100000];

int main()
{
    int n,m,k;
    int i,nans=0;
    memset(sta,0,sizeof(sta));
    cin >> n >> m >> k;
    for(i=1;i<=k;i++)
        ans[++nans]=1;
    ans[++nans]=n;
    if(k>1)
        for(i=2;i<=k;i++)
            ans[++nans]=n+1;
    if(2*n<=n+m)
        if(k==1)
        {
            ans[++nans]=n+m-1;
            if(n+m-1+n<=n+m+1)
                ans[++nans]=n+m;
        }
        else
            ans[++nans]=n+m;
    if(k==1&&2*n==n+m+1)
        ans[++nans]=n+1;
    cout << nans << endl;
    for(i=1;i<=nans;i++)
        cout << ans[i] << ' ';
    cout << endl;
    return 0;
}


#include <iostream>
#include <cstring>
using namespace std;

int main()
{
    int n,m,k;
    int i,sta[1010],nans=0,ans[1010];
    memset(sta,0,sizeof(sta));
    cin >> n >> m >> k;
    for(i=1;i<=k;i++)
        ans[++nans]=1;
    ans[++nans]=n;
    if(k>1)
        for(i=2;i<=k;i++)
            ans[++nans]=n+1;
    if(2*n<=n+m)
        if(k==1)
        {
            ans[++nans]=n+m-1;
            if(n+m-1+n<=n+m+1)
                ans[++nans]=n+m;
        }
        else
            ans[++nans]=n+m;
    if(k==1&&2*n==n+m+1)
        ans[++nans]=n+1;
    cout << nans << endl;
    for(i=1;i<=nans;i++)
        cout << ans[i] << ' ';
    cout << endl;
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<ctime>
#include<cstring>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<queue>

using namespace std;

int flag;
void print(int a)
{
	if(flag)	printf(" ");
	flag = 1;
	printf("%d", a);
}

int main()
{
	int n, m, k;
	while(~scanf("%d%d%d", &n, &m, &k))
	{
		flag = 0;
		int z = 0;
		if(n == m)
		{
			//1 , n - 1, n + 1, n + n
			z = k + (1) + (k - 1) + 1;
			printf("%d\n", z);

			for(int i = 1; i <= k; i++)
				print(1);

			print(n - 1);
			for(int i = 1; i < k; i++)
				print(n + 1);
			print(n + n);
			puts("");
			continue;
		}

		//1, n - 1, n + 1
		z = k + (1) + (k - 1);
		printf("%d\n", z);

		for(int i = 1; i <= k; i++)
			print(1);

		print(n - 1);
		for(int i = 1; i < k; i++)
			print(n + 1);
		puts("");
	}
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<ctime>
#include<cstring>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<queue>

using namespace std;

vector<int>ans;
int flag;
void print(int a)
{
	if(flag)	printf(" ");
	flag = 1;
	printf("%d", a);
}

const int maxn = 1010 * 4;
int cov[maxn];
#define PB(x) push_back(x)

int main()
{
	int n, m, k;
	while(~scanf("%d%d%d", &n, &m, &k))
	{
		memset(cov, 0, sizeof(cov));
		ans.clear();

		int tn = (n + m) * 2;
		for(int i = 1; i <= k; i++)
		{
			ans.PB(1);
			for(int j = 1; j <= tn; j+= n + m)
				cov[j]++;
			for(int j = n + 1; j <= tn; j += n + m)
				cov[j]--;
		}

		int sum = 0;
		for(int i = 1; i <= tn; i++)
		{
			sum += cov[i];
			if(sum >= k)	continue;
			if(sum == 0)
			{
				sum++;
				for(int j = i - 1; j <= tn; j += n + m)
					cov[j]++;
				for(int j = i - 1 + n; j <= tn; j += n + m)
					cov[j]--;

				ans.PB(i - 1);
			}

			while(sum < k)
			{
				sum++;
				for(int j = i; j <= tn; j += n + m)
					cov[j]++;
				for(int j = i + n; j <= tn; j += n + m)
					cov[j]--;

				ans.PB(i);
			}
		}

		printf("%d\n", ans.size());
		for(int i = 0; i < ans.size(); i++)
		{
			if(i)	putchar(' ');
			printf("%d", ans[i]);
		}
		puts("");
	}
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<ctime>
#include<cstring>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<queue>

using namespace std;

int flag;
void print(int a)
{
	if(flag)	printf(" ");
	flag = 1;
	printf("%d", a);
}

int main()
{
	int n, m, k;
	while(~scanf("%d%d%d", &n, &m, &k))
	{
		flag = 0;
		int z = 0;
		if(n == m && k != 1)
		{
			//1 , n , n + 1, n + n
			z = k + (1) + (k - 1) + 1;
			printf("%d\n", z);

			for(int i = 1; i <= k; i++)
				print(1);

			print(n);
			for(int i = 1; i < k; i++)
				print(n + 1);
			print(n + n);
			puts("");
			continue;
		}
		else
		if(n == m)
		{
			//1 , n , n + n - 1
			z = k + (1) + 1 ;
			printf("%d\n", z);

			for(int i = 1; i <= k; i++)
				print(1);

			print(n);
			print(n + n - 1);
			puts("");
			continue;
		}

		//1, n , n + 1
		z = k + (1) + (k - 1);
		printf("%d\n", z);

		for(int i = 1; i <= k; i++)
			print(1);

		print(n);
		for(int i = 1; i < k; i++)
			print(n + 1);
		puts("");
	}
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<ctime>
#include<cstring>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<queue>

using namespace std;

int flag;
void print(int a)
{
	if(flag)	printf(" ");
	flag = 1;
	printf("%d", a);
}

int main()
{
	int n, m, k;
	while(~scanf("%d%d%d", &n, &m, &k))
	{
		flag = 0;
		int z = 0;
		if(n == m && k != 1)
		{
			//1 , n , n + 1, n + n
			z = k + (1) + (k - 1) + 1;
			printf("%d\n", z);

			for(int i = 1; i <= k; i++)
				print(1);

			print(n);
			for(int i = 1; i < k; i++)
				print(n + 1);
			print(n + n);
			puts("");
			continue;
		}
		else
		{
			//1 , n , n + n - 1
			z = k + (1) + 1 ;
			printf("%d\n", z);

			for(int i = 1; i <= k; i++)
				print(1);

			print(n);
			print(n + n - 1);
			puts("");
			continue;
		}

		//1, n , n + 1
		z = k + (1) + (k - 1);
		printf("%d\n", z);

		for(int i = 1; i <= k; i++)
			print(1);

		print(n);
		for(int i = 1; i < k; i++)
			print(n + 1);
		puts("");
	}
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<ctime>
#include<cstring>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<queue>

using namespace std;

vector<int>ans;
int flag;
void print(int a)
{
	if(flag)	printf(" ");
	flag = 1;
	printf("%d", a);
}

const int maxn = 1010 * 4;
int cov[maxn];
#define PB(x) push_back(x)
set<int>st;

void myerase(int l,int r)
{
	set<int>::iterator it;
	while(1)
	{
		it = st.lower_bound(l);
		if(it == st.end())	return;
		if((*it) > r)	return;
		st.erase(it);
	}
}

int main()
{
	int n, m, k;
	while(~scanf("%d%d%d", &n, &m, &k))
	{
		memset(cov, 0, sizeof(cov));
		ans.clear();
		st.clear();

		int tn = 2*(n + m) + 10;
		for(int i = 2; i <= tn; i++)
			st.insert(i);

		for(int i = 1; i <= k; i++)
		{
			ans.PB(1);
			for(int j = 1; j <= tn; j+= n + m)
				cov[j]++, myerase(j + 1, j + n - 1);
			for(int j = n + 1; j <= tn; j += n + m)
				cov[j]--;
		}

		int sum = cov[1];;
		for(int i = 2; i <= tn; i++)
		{
			sum += cov[i];

			if(st.find(i) != st.end())
			{
				sum++;
				for(int j = i - 1; j <= tn; j += n + m)
					cov[j]++, myerase(j + 1, j + n - 1);
				for(int j = i - 1 + n; j <= tn; j += n + m)
					cov[j]--;

				ans.PB(i - 1);
			}

			while(sum < k)
			{
				sum++;
				for(int j = i; j <= tn; j += n + m)
					cov[j]++, myerase(j + 1, j + n - 1);
				for(int j = i + n; j <= tn; j += n + m)
					cov[j]--;

				ans.PB(i);
			}
		}

		printf("%d\n", ans.size());
		for(int i = 0; i < ans.size(); i++)
		{
			if(i)	putchar(' ');
			printf("%d", ans[i]);
		}
		puts("");
	}
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<ctime>
#include<cstring>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<queue>

using namespace std;

int flag;
void print(int a)
{
	if(flag)	printf(" ");
	flag = 1;
	printf("%d", a);
}

int main()
{
	int n, m, k;
	while(~scanf("%d%d%d", &n, &m, &k))
	{
		flag = 0;
		int z = 0;
		if(n == m && k != 1)
		{
			//1 , n , n + 1, n + n
			z = k + (1) + (k - 1) + 1;
			printf("%d\n", z);

			for(int i = 1; i <= k; i++)
				print(1);

			print(n);
			for(int i = 1; i < k; i++)
				print(n + 1);
			print(n + n);
			puts("");
			continue;
		}
		else
		if(n == m)
		{
			//1 , n , n + n - 1
			z = k + (1) + 1 ;
			printf("%d\n", z);

			for(int i = 1; i <= k; i++)
				print(1);

			print(n);
			print(n + n - 1);
			puts("");
			continue;
		}
		else
		if(k == 1)
		{
			printf("3\n");
			printf("%d %d %d\n", 1, n, n + 1);
			continue;
		}

		//1, n , n + 1
		z = k + (1) + (k - 1);
		printf("%d\n", z);

		for(int i = 1; i <= k; i++)
			print(1);

		print(n);
		for(int i = 1; i < k; i++)
			print(n + 1);
		puts("");
	}
	return 0;
}


#include<stdio.h>
#include<stdlib.h>
char c[100000];
int a[11300000];
long long int m = 11216973;
//int v = 1017;

int min(int a, int b)
{
	if (a>b)
		return b;
	else
		return a;
}

int hash(char a[],int n,int p,int q)
{
	long long int sum=0;
//	long long int sum1=0;
	int i;
	a[n]=0;
	for(i=n-1;i>-1;i--)
	{
		sum=((sum + a[i]+a[i+1]-'@'+1)*q)%p;
//		sum1=((sum + a[i]+a[i+1]-'|'+2)*q)%p;

	}
	return sum;
}

int main()
{
	int n;
	scanf("%d",&n);
	int i;

	for(i=0;i<n;i++)
	{
		scanf("%s",c);
		int l=strlen(c);
//		printf("%d\n",a[hash(c,l,m,41)]);
		int r1= ++a[hash(c,l,m,41)];
//		printf("%d\n",r1);
		//		int r2= b[hash(c,l,v,39)]++;
//		if(a[hash(c,l,m,101)] == 1) // && b[hash(c,l,v,39)]==1)
			if(r1 == 1)
			printf("OK\n");

		else
			printf("%s%d\n",c,r1-1);
	}

	return 0;
}


#include<stdio.h>
#include<stdlib.h>
char c[100000];
//int count[100000];
int a[100010];
int b[10070];
int m = 100000+7;
int v = 1017;
void min(int a, int b)
{
if (a>b)
return b;
else
return a;
}

int hash(char a[],int n,int p,int q)
{
	int sum=0;
	int i;
	for(i=n-1;i>-1;i--)
	{
		sum=((sum+a[i]-'~'+1)*q)%p;
	}
	return sum;
}

int main()
{
	int n;
	scanf("%d",&n);
	int i;

	for(i=0;i<n;i++)
	{
		scanf("%s",c);
		int l=strlen(c);
		int r1= a[hash(c,l,m,41)]++;
i//		int r2= b[hash(c,l,v,39)]++;
		if(a[hash(c,l,m,41)]==1)// && b[hash(c,l,v,39)]==1)
				printf("OK\n");

		else
			printf("%s%d\n",c,r1);
	}

	return 0;
}


#include<stdio.h>
#include<stdlib.h>
char c[100000];
int a[91300000];
long long int m = 91216973;
//int v = 1017;

int min(int a, int b)
{
	if (a>b)
		return b;
	else
		return a;
}

int hash(char a[],int n,int p,int q)
{
	long long int sum=0;
//	long long int sum1=0;
	int i;
	a[n]=0;
	for(i=n-1;i>-1;i--)
	{
		sum=((sum + a[i]+a[i+1]-'@'+1)*q)%p;
//		sum1=((sum + a[i]+a[i+1]-'|'+2)*q)%p;

	}
	return sum;
}

int main()
{
	int n;
	scanf("%d",&n);
	int i;

	for(i=0;i<n;i++)
	{
		scanf("%s",c);
		int l=strlen(c);
//		printf("%d\n",a[hash(c,l,m,41)]);
		int r1= ++a[hash(c,l,m,41)];
//		printf("%d\n",r1);
		//		int r2= b[hash(c,l,v,39)]++;
//		if(a[hash(c,l,m,101)] == 1) // && b[hash(c,l,v,39)]==1)
			if(r1 == 1)
			printf("OK\n");

		else
			printf("%s%d\n",c,r1-1);
	}

	return 0;
}


#include<stdio.h>
#include<stdlib.h>
char c[100000];
int a[11300000];
long long int m = 11216973;
//int v = 1017;

int min(int a, int b)
{
	if (a>b)
		return b;
	else
		return a;
}

int hash(char a[],int n,int p,int q)
{
	long long int sum=0;
//	long long int sum1=0;
	int i;
	a[n]=0;
	for(i=n-1;i>-1;i--)
	{
		sum=((sum + a[i]*a[i+1]+1)*q)%p;
//		sum1=((sum + a[i]+a[i+1]-'|'+2)*q)%p;

	}
	return sum;
}

int main()
{
	int n;
	scanf("%d",&n);
	int i;

	for(i=0;i<n;i++)
	{
		scanf("%s",c);
		int l=strlen(c);
//		printf("%d\n",a[hash(c,l,m,41)]);
		int r1= ++a[hash(c,l,m,41)];
//		printf("%d\n",r1);
		//		int r2= b[hash(c,l,v,39)]++;
//		if(a[hash(c,l,m,101)] == 1) // && b[hash(c,l,v,39)]==1)
			if(r1 == 1)
			printf("OK\n");

		else
			printf("%s%d\n",c,r1-1);
	}

	return 0;
}


#include<stdio.h>
#include<stdlib.h>
char c[100000];
int a[5130000];
int b[5130000];
long long int m = 1216973;
int v = 1213737;

int mini(int a, int b)
{
	if (a>b)
		return b;
	else
		return a;
}

int hash(char a[],int n,int p,int q)
{
	long long int sum=0;
//	long long int sum1=0;
	int i;
	a[n]=0;
	for(i=n-1;i>-1;i--)
	{
		sum=((sum + (a[i]-'A'+1)+(a[i+1]-'A'+1)*a[i+1]+1)*(q+q*q))%p;
//		sum1=((sum + a[i]+a[i+1]-'|'+2)*q)%p;

	}
	return sum;
}

int main()
{
	long long int n;
	scanf("%lld",&n);
	int i;

	for(i=0;i<n;i++)
	{
		scanf("%s",c);
		int l=strlen(c);
//		printf("%d\n",a[hash(c,l,m,41)]);
		int r1= ++a[hash(c,l,m,41)];
		int r2= ++b[hash(c,l,v,39)];
//		printf("%d %d\n",r1,r2);
//		if(a[hash(c,l,m,101)] == 1) // && b[hash(c,l,v,39)]==1)
			if(r1 == 1||r2 == 1)
			printf("OK\n");

		else
			printf("%s%d\n",c,mini(r1,r2)-1);
	}

	return 0;
}


#include<stdio.h>
#include<stdlib.h>
char c[100000];
int a[9130000];
int b[9130000];
long long int m = 1216973;
int v = 1213737;

int mini(int a, int b)
{
	if (a>b)
		return b;
	else
		return a;
}

int hash(char a[],int n,int p,int q)
{
	long long int sum=0;
//	long long int sum1=0;
	int i;
	a[n]=0;
	for(i=n-1;i>-1;i--)
	{
		sum=((sum + (a[i]-'A'+1)+(a[i+1]-'A'+1)*a[i+1]-'@'+1)*q)%p;
//		sum1=((sum + a[i]+a[i+1]-'|'+2)*q)%p;

	}
	return sum;
}

int main()
{
	long long int n;
	scanf("%lld",&n);
	int i;

	for(i=0;i<n;i++)
	{
		scanf("%s",c);
		int l=strlen(c);
//		printf("%d\n",a[hash(c,l,m,41)]);
		int r1= ++a[hash(c,l,m,41)];
		int r2= ++b[hash(c,l,v,39)];
//		printf("%d %d\n",r1,r2);
//		if(a[hash(c,l,m,101)] == 1) // && b[hash(c,l,v,39)]==1)
			if(r1 == 1||r2 == 1)
			printf("OK\n");

		else
			printf("%s%d\n",c,mini(r1,r2)-1);
	}

	return 0;
}


#include<stdio.h>
#include<stdlib.h>
char c[100000];
int a[5130000];
int d[5130000];
int b[5130000];
long long int m = 1216973;
int v = 3213737;

int mini(int a, int b)
{
	if (a>b)
		return b;
	else
		return a;
}

int hash(char a[],int n,int p,int q)
{
	long long int sum=0;
//	long long int sum1=0;
	int i;
	a[n]=0;
	for(i=n-1;i>-1;i--)
	{
		sum=((sum + (a[i]-'A'+1)+(a[i+1]-'A'+1)*a[i+1]+1)*(q+q*q))%p;
//		sum1=((sum + a[i]+a[i+1]-'|'+2)*q)%p;

	}
	return sum;
}

int main()
{
	long long int n;
	scanf("%lld",&n);
	int i;

	for(i=0;i<n;i++)
	{
		scanf("%s",c);
		int l=strlen(c);
//		printf("%d\n",a[hash(c,l,m,41)]);
		int r1= ++a[hash(c,l,m,41)];
		int r2= ++b[hash(c,l,v,39)];
		int r3= ++d[hash(c,l,v,431)];
//		printf("%d %d\n",r1,r2);
//		if(a[hash(c,l,m,101)] == 1) // && b[hash(c,l,v,39)]==1)
			if(r1 == 1||r2 == 1||r3==1)
			printf("OK\n");

		else
			printf("%s%d\n",c,mini(r1,r2)-1);
	}

	return 0;
}


#include<stdio.h>
#include<stdlib.h>
char c[100000];
int a[1130000];
int b[1130000];
long long int m = 1216973;
int v = 1213737;

int mini(int a, int b)
{
	if (a>b)
		return b;
	else
		return a;
}

int hash(char a[],int n,int p,int q)
{
	long long int sum=0;
//	long long int sum1=0;
	int i;
	a[n]=0;
	for(i=n-1;i>-1;i--)
	{
		sum=((sum + a[i]+a[i+1]*a[i+1]-'@'+1)*q)%p;
//		sum1=((sum + a[i]+a[i+1]-'|'+2)*q)%p;

	}
	return sum;
}

int main()
{
	int n;
	scanf("%d",&n);
	int i;

	for(i=0;i<n;i++)
	{
		scanf("%s",c);
		int l=strlen(c);
//		printf("%d\n",a[hash(c,l,m,41)]);
		int r1= ++a[hash(c,l,m,41)];
		int r2= ++b[hash(c,l,v,39)];
//		printf("%d %d\n",r1,r2);
//		if(a[hash(c,l,m,101)] == 1) // && b[hash(c,l,v,39)]==1)
			if(r1 == 1||r2 == 1)
			printf("OK\n");

		else
			printf("%s%d\n",c,mini(r1,r2)-1);
	}

	return 0;
}


#include<stdio.h>
#include<stdlib.h>
char c[100000];
//int count[100000];
int a[100010];
int b[10070];
int m = 100000+7;
int v = 1017;
void min(int a, int b)
{
if (a>b)
return b;
else
return a;
}

int hash(char a[],int n,int p,int q)
{
	int sum=0;
	int i;
	for(i=n-1;i>-1;i--)
	{
		sum=((sum+a[i]-'@'+1)*q)%p;
	}
	return sum;
}

int main()
{
	int n;
	scanf("%d",&n);
	int i;

	for(i=0;i<n;i++)
	{
		scanf("%s",c);
		int l=strlen(c);
		int r1= a[hash(c,l,m,41)]++;
//		int r2= b[hash(c,l,v,39)]++;
		if(a[hash(c,l,m,41)]==1) // && b[hash(c,l,v,39)]==1)
				printf("OK\n");

		else
			printf("%s%d\n",c,r1);
	}

	return 0;
}


#include<stdio.h>
#include<stdlib.h>
char c[100000];
int a[1130000];
int b[1130000];
long long int m = 1216973;
int v = 1213737;

int mini(int a, int b)
{
	if (a>b)
		return b;
	else
		return a;
}

int hash(char a[],int n,int p,int q)
{
	long long int sum=0;
//	long long int sum1=0;
	int i;
	a[n]=0;
	for(i=n-1;i>-1;i--)
	{
		sum=((sum + a[i]+a[i+1]*a[i+1]-'@'+1)*q)%p;
//		sum1=((sum + a[i]+a[i+1]-'|'+2)*q)%p;

	}
	return sum;
}

int main()
{
	int n;
	scanf("%d",&n);
	int i;

	for(i=0;i<n;i++)
	{
		scanf("%s",c);
		int l=strlen(c);
//		printf("%d\n",a[hash(c,l,m,41)]);
		int r1= ++a[hash(c,l,m,41)];
//		printf("%d\n",r1);
		int r2= b[hash(c,l,v,39)]++;
//		if(a[hash(c,l,m,101)] == 1) // && b[hash(c,l,v,39)]==1)
			if(r1 == 1||r2 == 1)
			printf("OK\n");

		else
			printf("%s%d\n",c,mini(r1,r2));
	}

	return 0;
}


#include<stdio.h>
#include<stdlib.h>
char c[100000];
//int count[100000];
int a[777770000];
int b[10070];
long long int m = 633651349;
int v = 1017;
int min(int a, int b)
{
if (a>b)
return b;
else
return a;
}

int hash(char a[],int n,int p,int q)
{
	int sum=0;
	int i;
	for(i=n-1;i>-1;i--)
	{
		sum=((sum+a[i]-'@'+1)*q)%p;
	}
	return sum;
}

int main()
{
	int n;
	scanf("%d",&n);
	int i;

	for(i=0;i<n;i++)
	{
		scanf("%s",c);
		int l=strlen(c);
		int r1= a[hash(c,l,m,41)]++;
//		int r2= b[hash(c,l,v,39)]++;
		if(a[hash(c,l,m,41)]==1) // && b[hash(c,l,v,39)]==1)
				printf("OK\n");

		else
			printf("%s%d\n",c,r1);
	}

	return 0;
}


#include<stdio.h>
#include<stdlib.h>
char c[100000];
int a[11300000];
long long int m = 11216973;
//int v = 1017;

int min(int a, int b)
{
	if (a>b)
		return b;
	else
		return a;
}

int hash(char a[],int n,int p,int q)
{
	long long int sum=0;
//	long long int sum1=0;
	int i;
	a[n]=0;
	for(i=n-1;i>-1;i--)
	{
		sum=((sum + a[i]*a[i+1]-'@'+1)*q)%p;
//		sum1=((sum + a[i]+a[i+1]-'|'+2)*q)%p;

	}
	return sum;
}

int main()
{
	int n;
	scanf("%d",&n);
	int i;

	for(i=0;i<n;i++)
	{
		scanf("%s",c);
		int l=strlen(c);
//		printf("%d\n",a[hash(c,l,m,41)]);
		int r1= ++a[hash(c,l,m,41)];
//		printf("%d\n",r1);
		//		int r2= b[hash(c,l,v,39)]++;
//		if(a[hash(c,l,m,101)] == 1) // && b[hash(c,l,v,39)]==1)
			if(r1 == 1)
			printf("OK\n");

		else
			printf("%s%d\n",c,r1-1);
	}

	return 0;
}


#include<stdio.h>
#include<stdlib.h>
char c[100000];
//int count[100000];
int a[1300000];
int b[10070];
long long int m = 1216973;
int v = 1017;
int min(int a, int b)
{
if (a>b)
return b;
else
return a;
}

int hash(char a[],int n,int p,int q)
{
	int sum=0;
	int i;
	for(i=n-1;i>-1;i--)
	{
		sum=((sum+a[i]-'@'+1)*q)%p;
	}
	return sum;
}

int main()
{
	int n;
	scanf("%d",&n);
	int i;

	for(i=0;i<n;i++)
	{
		scanf("%s",c);
		int l=strlen(c);
		int r1= a[hash(c,l,m,41)]++;
//		int r2= b[hash(c,l,v,39)]++;
		if(a[hash(c,l,m,41)]==1) // && b[hash(c,l,v,39)]==1)
				printf("OK\n");

		else
			printf("%s%d\n",c,r1);
	}

	return 0;
}


#include<stdio.h>
#include<stdlib.h>
char c[100000];
int a[5130000];
int d[5130000];
int b[5130000];
long long int m = 1216973;
long long int v = 3213737;
long long int l = 5124111;
int mini(int a, int b)
{
	if (a>b)
		return b;
	else
		return a;
}

int hash(char a[],int n,int p,int q)
{
	long long int sum=0;
//	long long int sum1=0;
	int i;
	a[n]=0;
	for(i=n-1;i>-1;i--)
	{
		sum=((sum + (a[i]-'A'+1)^(a[i+1]-1)+(a[i+1]-'A'+1)*a[i+1]+1)*(q+q*q))%p;
//		sum1=((sum + a[i]+a[i+1]-'|'+2)*q)%p;

	}
	return sum;
}

int main()
{
	long long int n;
	scanf("%lld",&n);
	int i;

	for(i=0;i<n;i++)
	{
		scanf("%s",c);
		int l=strlen(c);
//		printf("%d\n",a[hash(c,l,m,41)]);
		int r1= ++a[hash(c,l,m,41)];
		int r2= ++b[hash(c,l,v,39)];
		int r3= ++d[hash(c,l,v,431)];
//		printf("%d %d\n",r1,r2);
//		if(a[hash(c,l,m,101)] == 1) // && b[hash(c,l,v,39)]==1)
			if(r1 == 1||r2 == 1||r3==1)
			printf("OK\n");

		else
			printf("%s%d\n",c,mini(r1,r2)-1);
	}

	return 0;
}


#include<stdio.h>
#include<stdlib.h>
char c[100000];
//int count[100000];
int a[1000000000];
int b[10070];
long long int m = 633651349;
int v = 1017;
void min(int a, int b)
{
if (a>b)
return b;
else
return a;
}

int hash(char a[],int n,int p,int q)
{
	int sum=0;
	int i;
	for(i=n-1;i>-1;i--)
	{
		sum=((sum+a[i]-'@'+1)*q)%p;
	}
	return sum;
}

int main()
{
	int n;
	scanf("%d",&n);
	int i;

	for(i=0;i<n;i++)
	{
		scanf("%s",c);
		int l=strlen(c);
		int r1= a[hash(c,l,m,41)]++;
//		int r2= b[hash(c,l,v,39)]++;
		if(a[hash(c,l,m,41)]==1) // && b[hash(c,l,v,39)]==1)
				printf("OK\n");

		else
			printf("%s%d\n",c,r1);
	}

	return 0;
}


#include<stdio.h>
#include<stdlib.h>
char c[100000];
//int count[100000];
int a[100010];
int b[10070];
int m = 100000+7;
int v = 1017;
void min(int a, int b)
{
if (a>b)
return b;
else
return a;
}

int hash(char a[],int n,int p,int q)
{
	int sum=0;
	int i;
	for(i=n-1;i>-1;i--)
	{
		sum=((sum+a[i]-'~'+1)*q)%p;
	}
	return sum;
}

int main()
{
	int n;
	scanf("%d",&n);
	int i;

	for(i=0;i<n;i++)
	{
		scanf("%s",c);
		int l=strlen(c);
		int r1= a[hash(c,l,m,41)]++;
//		int r2= b[hash(c,l,v,39)]++;
		if(a[hash(c,l,m,41)]==1) // && b[hash(c,l,v,39)]==1)
				printf("OK\n");

		else
			printf("%s%d\n",c,r1);
	}

	return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<string.h>
const int mod =2069;
typedef struct list
{
	char str[33];
	int freq;
	struct list* link;
} Node;
Node* arr[2069];
long long int power (int a,int b)
{
	int i;
	long long int val=0;
	for (i=0;i<b;i++)
	{
		val=(val+(3*i))%mod;
	}
	val=val*a;
	return val;
}
long long int  hash (Node* temp,int x)
{
	int i;
	long long int val=0;
	for (i=0;i<x;i++)
	{
		val=val+(power (temp->str[i]-96,x))%mod;
	}
	val=val%mod;
	return val;
}
int main()
{
	int n,i;
	scanf ("%d",&n);
	for (i=0;i<2069;i++)
	{
		arr[i]=NULL;
	}
	for (i=0;i<n;i++)
	{
		long long int index;
		Node* temp=(Node*) malloc (sizeof (Node));
		scanf ("%s",temp->str);
		temp->freq=1;
		temp->link=NULL;
		int x=strlen (temp->str);
		index=hash (temp,x);
		if (arr[index]==NULL)
		{
			arr[index]=temp;
		}
		else
		{
			Node* temp2=arr[index];
			int j;
			while (temp2!=NULL)
			{
				int flag=1;
				for (j=0;j<32;j++)
				{
					if (temp->str[j]!=temp2->str[j])
					{
						flag=0;
						break;
					}
				}
				if (flag==1)
				{
					temp2->freq++;
					temp->freq=temp2->freq;;
					break;
				}
				temp2=temp2->link;
			}
		}
		if (temp->freq==1)
			printf ("OK\n");
		else
			printf ("%s%d\n",temp->str,temp->freq-1);
	}
	return 0;
}


#include<stdio.h>
#include<stdlib.h>
char c[100000];
int a[11300000];
long long int m = 11216973;
//int v = 1017;

int min(int a, int b)
{
	if (a>b)
		return b;
	else
		return a;
}

int hash(char a[],int n,int p,int q)
{
	long long int sum=0;
//	long long int sum1=0;
	int i;
	a[n]=0;
	for(i=n-1;i>-1;i--)
	{
		sum=((sum + a[i]+a[i+1]*a[i+1]-'@'+1)*q)%p;
//		sum1=((sum + a[i]+a[i+1]-'|'+2)*q)%p;

	}
	return sum;
}

int main()
{
	int n;
	scanf("%d",&n);
	int i;

	for(i=0;i<n;i++)
	{
		scanf("%s",c);
		int l=strlen(c);
//		printf("%d\n",a[hash(c,l,m,41)]);
		int r1= ++a[hash(c,l,m,41)];
//		printf("%d\n",r1);
		//		int r2= b[hash(c,l,v,39)]++;
//		if(a[hash(c,l,m,101)] == 1) // && b[hash(c,l,v,39)]==1)
			if(r1 == 1)
			printf("OK\n");

		else
			printf("%s%d\n",c,r1-1);
	}

	return 0;
}


#include<stdio.h>
#include<stdlib.h>
char c[100000];
int a[5130000];
int b[5130000];
long long int m = 1216973;
int v = 1213737;

int mini(int a, int b)
{
	if (a>b)
		return b;
	else
		return a;
}

int hash(char a[],int n,int p,int q)
{
	long long int sum=0;
//	long long int sum1=0;
	int i;
	a[n]=0;
	for(i=n-1;i>-1;i--)
	{
		sum=((sum + (a[i]-'A'+1)+(a[i+1]-'A'+1)*a[i+1]-'@'+1)*q)%p;
//		sum1=((sum + a[i]+a[i+1]-'|'+2)*q)%p;

	}
	return sum;
}

int main()
{
	long long int n;
	scanf("%lld",&n);
	int i;

	for(i=0;i<n;i++)
	{
		scanf("%s",c);
		int l=strlen(c);
//		printf("%d\n",a[hash(c,l,m,41)]);
		int r1= ++a[hash(c,l,m,41)];
		int r2= ++b[hash(c,l,v,39)];
//		printf("%d %d\n",r1,r2);
//		if(a[hash(c,l,m,101)] == 1) // && b[hash(c,l,v,39)]==1)
			if(r1 == 1||r2 == 1)
			printf("OK\n");

		else
			printf("%s%d\n",c,mini(r1,r2)-1);
	}

	return 0;
}


#include<stdio.h>
#include<stdlib.h>
char c[100000];
//int count[100000];
int a[100010];
int b[10070];
int m = 100000+7;
int v = 1017;
void min(int a, int b)
{
if (a>b)
return b;
else
return a;
}

int hash(char a[],int n,int p,int q)
{
	int sum=0;
	int i;
	for(i=n-1;i>-1;i--)
	{
		sum=((sum+a[i]-'a'+1)*q)%p;
	}
	return sum;
}

int main()
{
	int n;
	scanf("%d",&n);
	int i;

	for(i=0;i<n;i++)
	{
		scanf("%s",c);
		int l=strlen(c);
		int r1= a[hash(c,l,m,41)]++;
		int r2= b[hash(c,l,v,39)]++;
		if(a[hash(c,l,m,41)]==1 && b[hash(c,l,v,39)]==1)
				printf("OK\n");

		else
			printf("%s%d\n",c,r1);
	}

	return 0;
}


#include<stdio.h>
#include<stdlib.h>
char c[100000];
int a[11300000];
int b[11300000];
long long int m = 11216973;
int v = 11213737;

int mini(int a, int b)
{
	if (a>b)
		return b;
	else
		return a;
}

int hash(char a[],int n,int p,int q)
{
	long long int sum=0;
//	long long int sum1=0;
	int i;
	a[n]=0;
	for(i=n-1;i>-1;i--)
	{
		sum=((sum + a[i]+a[i+1]*a[i+1]-'@'+1)*q)%p;
//		sum1=((sum + a[i]+a[i+1]-'|'+2)*q)%p;

	}
	return sum;
}

int main()
{
	int n;
	scanf("%d",&n);
	int i;

	for(i=0;i<n;i++)
	{
		scanf("%s",c);
		int l=strlen(c);
//		printf("%d\n",a[hash(c,l,m,41)]);
		int r1= ++a[hash(c,l,m,41)];
//		printf("%d\n",r1);
		int r2= b[hash(c,l,v,39)]++;
//		if(a[hash(c,l,m,101)] == 1) // && b[hash(c,l,v,39)]==1)
			if(r1 == 1||r2 == 1)
			printf("OK\n");

		else
			printf("%s%d\n",c,mini(r1,r2));
	}

	return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<string.h>
char c[100000];
int a[5130000];
int d[5130000];
int b[5130000];
long long int m = 1216973;
long long int v = 3213737;
long long int l = 5124111;
int mini(int a, int b)
{
	if (a>b)
		return b;
	else
		return a;
}

int hash(char a[],int n,int p,int q)
{
	long long int sum=0;
	int i;
	a[n]=0;
	for(i=n-1;i>-1;i--)
	{
		if(a[i]%2)
		sum=((sum + (a[i])*a[i]+a[i+1])*q)%p;
		else
		sum=((sum+a[i+1]*a[i]+a[i])*(1+q*q))%p;

	}
	return sum;
}

int main()
{
	long long int n;
	scanf("%lld",&n);
	int i;

	for(i=0;i<n;i++)
	{
		scanf("%s",c);
		int l=strlen(c);
		int r1= ++a[hash(c,l,m,37)];
		int r2= ++b[hash(c,l,v,31)];
//		int r3= ++d[hash(c,l,v,431)];
			if(r1 == 1||r2 == 1)//||r3==1)
			printf("OK\n");

		else
			printf("%s%d\n",c,mini(r1,r2)-1);

//			printf("%d\n",hash(c,l,m,41));
	}

	return 0;
}


#include<stdio.h>
#include<stdlib.h>
char c[100000];
int a[5130000];
int b[5130000];
long long int m = 1216973;
int v = 1213737;

int mini(int a, int b)
{
	if (a>b)
		return b;
	else
		return a;
}

int hash(char a[],int n,int p,int q)
{
	long long int sum=0;
//	long long int sum1=0;
	int i;
	a[n]=0;
	for(i=n-1;i>-1;i--)
	{
		sum=((sum + (a[i]-'A'+1)+(a[i+1]-'A'+1)*a[i+1]+1)*q)%p;
//		sum1=((sum + a[i]+a[i+1]-'|'+2)*q)%p;

	}
	return sum;
}

int main()
{
	long long int n;
	scanf("%lld",&n);
	int i;

	for(i=0;i<n;i++)
	{
		scanf("%s",c);
		int l=strlen(c);
//		printf("%d\n",a[hash(c,l,m,41)]);
		int r1= ++a[hash(c,l,m,41)];
		int r2= ++b[hash(c,l,v,39)];
//		printf("%d %d\n",r1,r2);
//		if(a[hash(c,l,m,101)] == 1) // && b[hash(c,l,v,39)]==1)
			if(r1 == 1||r2 == 1)
			printf("OK\n");

		else
			printf("%s%d\n",c,mini(r1,r2)-1);
	}

	return 0;
}


#include<stdio.h>
#include<stdlib.h>
char c[100000];
int a[5130000];
int d[5130000];
int b[5130000];
long long int m = 1216973;
int v = 3213737;

int mini(int a, int b)
{
	if (a>b)
		return b;
	else
		return a;
}

int hash(char a[],int n,int p,int q)
{
	long long int sum=0;
//	long long int sum1=0;
	int i;
	a[n]=0;
	for(i=n-1;i>-1;i--)
	{
		sum=((sum + (a[i]-'A'+1)+(a[i+1]-'A'+1)*a[i+1]+1)*(q+q*q))%p;
//		sum1=((sum + a[i]+a[i+1]-'|'+2)*q)%p;

	}
	return sum;
}

int main()
{
	long long int n;
	scanf("%lld",&n);
	int i;

	for(i=0;i<n;i++)
	{
		scanf("%s",c);
		int l=strlen(c);
//		printf("%d\n",a[hash(c,l,m,41)]);
		int r1= ++a[hash(c,l,m,41)];
		int r2= ++b[hash(c,l,v,39)];
		int r3= ++c[hash(c,l,v,431)];
//		printf("%d %d\n",r1,r2);
//		if(a[hash(c,l,m,101)] == 1) // && b[hash(c,l,v,39)]==1)
			if(r1 == 1||r2 == 1||r3==1)
			printf("OK\n");

		else
			printf("%s%d\n",c,mini(r1,r2)-1);
	}

	return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<string.h>
char c[100000];
int a[5130000];
int d[5130000];
int b[5130000];
long long int m = 1216973;
long long int v = 3213737;
long long int l = 5124111;
int mini(int a, int b)
{
	if (a>b)
		return b;
	else
		return a;
}

int hash(char a[],int n,int p,int q)
{
	long long int sum=0;
	int i;
	a[n]=0;
	for(i=n-1;i>-1;i--)
	{
		if(a[i]%2)
		sum=((sum + (a[i])*(a[i]+a[i+1])*q))%p;
		else
		sum+=((a[i+1]*a[i]+a[i])*(1+q*q))%p;

	}
	return sum;
}

int main()
{
	long long int n;
	scanf("%lld",&n);
	int i;

	for(i=0;i<n;i++)
	{
		scanf("%s",c);
		int l=strlen(c);
		int r1= ++a[hash(c,l,m,41)];
		int r2= ++b[hash(c,l,v,39)];
//		int r3= ++d[hash(c,l,v,431)];
			if(r1 == 1||r2 == 1)//||r3==1)
			printf("OK\n");

		else
			printf("%s%d\n",c,mini(r1,r2)-1);

//			printf("%d\n",hash(c,l,m,41));
	}

	return 0;
}


#include<stdio.h>
#include<stdlib.h>
char c[100000];
int a[5130000];
int d[5130000];
int b[5130000];
long long int m = 1216973;
long long int v = 3213737;
long long int l = 5124111;
int mini(int a, int b)
{
	if (a>b)
		return b;
	else
		return a;
}

int hash(char a[],int n,int p,int q)
{
	long long int sum=0;
//	long long int sum1=0;
	int i;
	a[n]=0;
	for(i=n-1;i>-1;i--)
	{
		sum=((sum + (a[i]-'A'+1)+(a[i+1]-'A'+1)*a[i+1]+1)*(q+q*q))%p;
//		sum1=((sum + a[i]+a[i+1]-'|'+2)*q)%p;

	}
	return sum;
}

int main()
{
	long long int n;
	scanf("%lld",&n);
	int i;

	for(i=0;i<n;i++)
	{
		scanf("%s",c);
		int l=strlen(c);
//		printf("%d\n",a[hash(c,l,m,41)]);
		int r1= ++a[hash(c,l,m,41)];
		int r2= ++b[hash(c,l,v,39)];
		int r3= ++d[hash(c,l,v,431)];
//		printf("%d %d\n",r1,r2);
//		if(a[hash(c,l,m,101)] == 1) // && b[hash(c,l,v,39)]==1)
			if(r1 == 1||r2 == 1||r3==1)
			printf("OK\n");

		else
			printf("%s%d\n",c,mini(r1,r2)-1);
	}

	return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAXLEN 32
#define	LEN_NUMBER_SUM (1 + MAXLEN / 2) * (MAXLEN - 1)
#define N 'z' * LEN_NUMBER_SUM

struct user
{
	int count;
	char s[MAXLEN + 1];
	struct user *next;
};

struct user* inituser(char *s)
{
	struct user *new = malloc(sizeof(struct user));
	new->next = NULL;
	memcpy(new->s, s, strlen(s) + 1);
	new->count = 1;
	return new;
}

void
insert(struct user **head, char *s)
{
	struct user *cur;
	if(*head == NULL)
	{
		*head = inituser(s);
		printf("OK\n");
		return;
	}
	cur = *head;
	while(cur->next != NULL)
	{
		if(strcmp(cur->s, s) == 0)
		{
			printf("%s%d\n", s, cur->count);
			cur->count++;
			return;
		}
		cur = cur->next;
	}
	if(strcmp(cur->s, s) == 0)
	{
		printf("%s%d\n", s, cur->count);
		cur->count++;
		return;
	}
	cur->next = inituser(s);
	printf("OK\n");
}

void
deletelist(struct user *head)
{
	struct user *cur = head;
	if(head == NULL)
		return;
	while(cur->next != NULL)
	{
		head = cur;
		cur = cur->next;
		free(head);
	}
	if(cur->next == NULL)
		free(cur);
}

int
hashfun(char *s)
{
	int res = 0, len = strlen(s), i;
	for(i = 0; i < len; i++)
		res += s[i] + i;
	return res;
}

int
main(void)
{
	int n, i;
	char s[MAXLEN];
	struct user *table[N];
	for(i = 0; i < N; i++)
		table[i] = NULL;
	scanf("%d", &n);
	for(i = 0; i < n; i++)
	{
		int h;
		scanf("%32s", s);
		h = hashfun(s);
		insert(&table[h], s);
	}
	for(i = 0; i < N; i++)
		deletelist(table[i]);
	return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAXLEN 32
#define	LEN_NUMBER_SUM (1 + MAXLEN / 2) * (MAXLEN - 1)
#define N 'z' * LEN_NUMBER_SUM

struct user
{
	int count;
	char s[MAXLEN + 1];
	struct user *next;
};

struct user* inituser(char *s)
{
	struct user *new = malloc(sizeof(struct user));
	memcpy(new->s, s, strlen(s) + 1);
	new->count = 1;
	return new;
}

void
insert(struct user **head, char *s)
{
	struct user *cur;
	if(*head == NULL)
	{
		*head = inituser(s);
		printf("OK\n");
		return;
	}
	cur = *head;
	while(cur->next != NULL)
	{
		if(strcmp(cur->s, s) == 0)
		{
			printf("%s%d\n", s, cur->count);
			cur->count++;
			return;
		}
		cur = cur->next;
	}
	if(strcmp(cur->s, s) == 0)
	{
		printf("%s%d\n", s, cur->count);
		cur->count++;
		return;
	}
	cur->next = inituser(s);
	printf("OK\n");
}

void deletelist(struct user *head)
{
	struct user *cur = head;
	if(head == NULL)
		return;
	while(cur->next != NULL)
	{
		head = cur;
		cur = cur->next;
		free(head);
	}
	if(cur->next == NULL)
		free(cur);
}

int
hashfun(char *s)
{
	int res = 0, len = strlen(s), i;
	for(i = 0; i < len; i++)
		res += s[i] + i;
	return res;
}

int
main(void)
{
	int n, i;
	char s[MAXLEN];
	struct user *table[N];
	for(i = 0; i < N; i++)
		table[i] = NULL;
	scanf("%d", &n);
	for(i = 0; i < n; i++)
	{
		int h;
		scanf("%32s", s);
		h = hashfun(s);
		insert(&table[h], s);
	}
	for(i = 0; i < N; i++)
		deletelist(table[i]);
	return 0;
}


#include <stdio.h>
typedef struct {
  int child[26];
  int count;
} NODE;
NODE nodes[1000000];
int nodesCount;

int createNode() {
  int i;
  nodes[nodesCount].count = -1;
  for (i = 0; i < 26; i++)
    nodes[nodesCount].child[i] = -1;
  nodesCount++;
  return nodesCount - 1;
}

int insert(char str[]) {
  int t =  0, i, index;
  for (i = 0; str[i]; i++) {
    index = str[i] - 'a';
    if (nodes[t].child[index] == -1)
      nodes[t].child[index] = createNode();
    t = nodes[t].child[index];
  }
  nodes[t].count++;
  return nodes[t].count;
}

int main() {
  int n, v;
  char str[33];
  scanf("%d", &n);
  getchar();
  createNode();
  while (n--) {
    scanf("%[^\n]%*c", str);
    v = insert(str);
    if (v == 0)
      printf("OK\n");
    else printf("%s%d\n", str, v);
  }

  return 0;
}


#include <stdio.h>

typedef struct {
  int child[26];
  unsigned long int count;
} NODE;
NODE nodes[100000];
int nodesCount;

/*int memory[SIZE + 1][2];
int hash(char str[]) {
  int value = 0, m = SIZE, pow_p = 31, p = 1, i, c;
  for (i = 0; str[i]; i++) {
    c = (int)str[i];
    value = (value + ((c + 1) * p) % m) % m;
    p = (pow_p * p) % m;
  }
  value %= m;
  if (value < 0)
    value += m;
  return value;
}*/

int createNode() {
  int i;
  nodes[nodesCount].count = -1;
  for (i = 0; i < 26; i++)
    nodes[nodesCount].child[i] = -1;
  nodesCount++;
  return nodesCount - 1;
}

int insert(char str[]) {
  int t =  0, i, index;
  for (i = 0; str[i]; i++) {
    index = str[i] - 'a';
    if (nodes[t].child[index] == -1)
      nodes[t].child[index] = createNode();
    t = nodes[t].child[index];
  }
  nodes[t].count++;
  return nodes[t].count;
}

int main() {

  int n;
  unsigned long int v;
  char str[33];
  scanf("%d", &n);
  getchar();
  createNode();
  while (n--) {
    scanf("%[^\n]%*c", str);
    v = insert(str);
    if (v == 0)
      printf("OK\n");
    else printf("%s%lu\n", str, v);

  }

  return 0;
}


#include <stdio.h>
typedef struct {
  int child[26];
  int count;
} NODE;
NODE nodes[400000];
int nodesCount;

int createNode() {
  int i;
  nodes[nodesCount].count = -1;
  for (i = 0; i < 26; i++)
    nodes[nodesCount].child[i] = -1;
  nodesCount++;
  return nodesCount - 1;
}

int insert(char str[]) {
  int t =  0, i, index;
  for (i = 0; str[i]; i++) {
    index = str[i] - 'a';
    if (nodes[t].child[index] == -1)
      nodes[t].child[index] = createNode();
    t = nodes[t].child[index];
  }
  nodes[t].count++;
  return nodes[t].count;
}

int main() {
  int n, v;
  char str[33];
  scanf("%d", &n);
  getchar();
  createNode();
  while (n--) {
    scanf("%[^\n]%*c", str);
    v = insert(str);
    if (v == 0)
      printf("OK\n");
    else printf("%s%d\n", str, v);
  }

  return 0;
}


#include <stdio.h>
#define SIZE 100003

unsigned long memory[SIZE + 1];
int hash(char str[]) {
  int value = 0, m = SIZE, pow_p = 31, p = 1, i, c;
  for (i = 0; str[i]; i++) {
    c = (int)str[i];
    value = (value + ((c + 1) * p) % m) % m;
    p = (pow_p * p) % m;
  }
  value %= m;
  if (value < 0)
    value += m;
  return value;
}

unsigned long insert(char str[]) {
  /*int t =  0, i, index;
  for (i = 0; str[i]; i++) {
    index = str[i] - 'a';
    if (nodes[t].child[index] == -1)
      nodes[t].child[index] = createNode();
    t = nodes[t].child[index];
  }
  nodes[t].count++;
  return nodes[t].count;*/
  int h = hash(str);
  memory[h]++;
  return memory[h] - 1;
}

int main() {

  int n;
  unsigned long int v;
  char str[33];
  scanf("%d", &n);
  getchar();
  createNode();
  while (n--) {
    scanf("%[^\n]%*c", str);
    v = insert(str);
    if (v == 0)
      printf("OK\n");
    else printf("%s%lu\n", str, v);

  }

  return 0;
}


#include <stdio.h>

typedef struct {
  int child[26];
  unsigned long int count;
} NODE;
NODE nodes[3200000];
int nodesCount;

/*int memory[SIZE + 1][2];
int hash(char str[]) {
  int value = 0, m = SIZE, pow_p = 31, p = 1, i, c;
  for (i = 0; str[i]; i++) {
    c = (int)str[i];
    value = (value + ((c + 1) * p) % m) % m;
    p = (pow_p * p) % m;
  }
  value %= m;
  if (value < 0)
    value += m;
  return value;
}*/

int createNode() {
  int i;
  nodes[nodesCount].count = -1;
  for (i = 0; i < 26; i++)
    nodes[nodesCount].child[i] = -1;
  nodesCount++;
  return nodesCount - 1;
}

int insert(char str[]) {
  int t =  0, i, index;
  for (i = 0; str[i]; i++) {
    index = str[i] - 'a';
    if (nodes[t].child[index] == -1)
      nodes[t].child[index] = createNode();
    t = nodes[t].child[index];
  }
  nodes[t].count++;
  return nodes[t].count;
}

int main() {

  int n;
  unsigned long int v;
  char str[33];
  scanf("%d", &n);
  getchar();
  createNode();
  while (n--) {
    scanf("%[^\n]%*c", str);
    v = insert(str);
    if (v == 0)
      printf("OK\n");
    else printf("%s%lu\n", str, v);

  }

  return 0;
}


#include <stdio.h>
#define SIZE 100003
typedef struct {
  int child[26];
  unsigned long int count;
} NODE;
NODE nodes[100000];
int nodesCount;

unsigned long memory[SIZE + 1];
int hash(char str[]) {
  int value = 0, m = SIZE, pow_p = 31, p = 1, i, c;
  for (i = 0; str[i]; i++) {
    c = (int)str[i];
    value = (value + ((c + 1) * p) % m) % m;
    p = (pow_p * p) % m;
  }
  value %= m;
  if (value < 0)
    value += m;
  return value;
}

int createNode() {
  int i;
  nodes[nodesCount].count = -1;
  for (i = 0; i < 26; i++)
    nodes[nodesCount].child[i] = -1;
  nodesCount++;
  return nodesCount - 1;
}

unsigned long insert(char str[]) {
  /*int t =  0, i, index;
  for (i = 0; str[i]; i++) {
    index = str[i] - 'a';
    if (nodes[t].child[index] == -1)
      nodes[t].child[index] = createNode();
    t = nodes[t].child[index];
  }
  nodes[t].count++;
  return nodes[t].count;*/
  int h = hash(str);
  memory[h]++;
  return memory[h] - 1;
}

int main() {
  int n;
  unsigned long int v;
  char str[33];
  scanf("%d", &n);
  getchar();
  while (n--) {
    scanf("%[^\n]%*c", str);
    v = insert(str);
    if (v == 0)
      printf("OK\n");
    else printf("%s%lu\n", str, v);

  }

  return 0;
}


#include <stdio.h>
#include <string.h>
int checkMe(char inp[100000][33],int n,int count)
{
    int i;
    int check=0;
    for (i=0;i<count;i++)
    {
        if (strcmp(inp[i],inp[count])==0)
        {
            check++;
        }
    }
    return check;
}
int main()
{
    int n,i,a=0;
    char inp[100000][33];
    scanf ("%d",&n);

    for (i=0;i<n;i++)
    {
        scanf("%s",&inp[i]);
        a=checkMe (inp,n,i);
        if (a==0)
            printf ("OK\n");
        else printf ("%s%d\n",inp[i],a);
    }
}


#include <stdio.h>
#include <string.h>
int checkMe(char inp[10000][33],int n,int count)
{
    int i;
    int check=0;
    for (i=0;i<count;i++)
    {
        if (strcmp(inp[i],inp[count])==0)
        {
            check++;
        }
    }
    return check;
}
int main()
{
    int n,i,a=0;
    char inp[10000][33];
    scanf ("%d",&n);

    for (i=0;i<n;i++)
    {
        scanf("%s",&inp[i]);
        a=checkMe (inp,n,i);
        if (a==0)
            printf ("OK\n");
        else printf ("%s%d\n",inp[i],a);
    }
}


#include <stdio.h>
#include <string.h>
int main ()
{
    int n,i,s=0;
    scanf ("%d",&n);

    char a[10000][33],b[33];
    int c[10000];

    while (n--)
    {
        scanf ("%s",&b);
        for (i=0;i<s;i++)
        {
            if (strcmp(a[i],b)==0)
                break;
        }
        if (i==s)
        {
            printf ("OK\n");
            strcpy(a[s],b);
            s++;
        }
        else
        {
            c[i]++;
            printf ("%s%d\n",b,c[i]);
        }
    }
}


#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <ctype.h>

/*───▄▀▀▀▄▄▄▄▄▄▄▀▀▀▄───
  ───█▒▒░░░░░░░░░▒▒█───
  ────█░░█░░░░░█░░█────
  ─▄▄──█░░░▀█▀░░░█──▄▄─
  █░░█─▀▄░░░░░░░▄▀─█░░█*/

char a[100000][33], b[33];

int n[100000];

int main(){

	int t, i, j, f, ind1 = 0, ind2 = 0;

	scanf("%d", &t);

	for(i = 0; i < t; i++){

	    f = 0;

		scanf("%s", b);

		for(j = 0; j < ind1; j++){

			if(strcmp(b, a[j]) == 0){
				f = 1;
				break;
			}

		}

        if(!f){
		printf("OK\n", b);

		strcpy(a[ind1], b);

		ind1++;

		continue;
        }

		else{
		    n[j] ++;
		    printf("%s%d\n", b, n[j]);
	    }
	}

	return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <ctype.h>

/*───▄▀▀▀▄▄▄▄▄▄▄▀▀▀▄───
  ───█▒▒░░░░░░░░░▒▒█───
  ────█░░█░░░░░█░░█────
  ─▄▄──█░░░▀█▀░░░█──▄▄─
  █░░█─▀▄░░░░░░░▄▀─█░░█*/

char a[100000][33], b[33];

int n[100000];

int main(){

	int t, i, j, f, ind1 = 0, ind2 = 0;

	scanf("%d", &t);

	char a[t + 1][1000000];

	for(i = 0; i < t; i++){

	    f = 0;

		scanf("%s", b);

		for(j = 0; j < ind1; j++){

			if(strcmp(b, a[j]) == 0){
				f = 1;
				break;
			}

		}

        if(!f){
		printf("OK\n", b);

		strcpy(a[ind1], b);

		ind1++;

		continue;
        }

		else{
		    n[j] ++;
		    printf("%s%d\n", b, n[j]);
	    }
	}

	return 0;
}


#include<stdio.h>
#include<string.h>
char a[1000000][500];
int main()
{
    int i,j,n,k = 0,l=0,m,c;
    char b[500];
    scanf("%d",&n);
    getchar();
    for(i = 0; i < n; i++)
    {
        scanf("%s",a[i]);
        getchar();
    }
    for(i = 0; i < n; i++)
    {
        for(j = 0; j < i; j++)
        {
            if(strcmp(a[i],a[j]) == 0)
            {
                k = 1;
                l++;
            }
        }
        if(k == 1)
        {
            strcpy(b,a[i]);
            m = strlen(b);
            for(c = 0; c < m; c++)
            {
                printf("%c",b[c]);
            }
            printf("%d\n",l);
            l = 0;
            k = 0;
        }
        else
        {
            printf("OK\n");
        }
    }
    return 0;

}


#include<stdio.h>
#include<string.h>
char a[100000][500];
int main()
{
    int i,j,n,k = 0,l=0;
    scanf("%d",&n);
    getchar();
    for(i = 0; i < n; i++)
    {
        scanf("%s",a[i]);
        getchar();
    }
    for(i = 0; i < n; i++)
    {
        for(j = 0; j < i; j++)
        {
            if(strcmp(a[i],a[j]) == 0)
            {
                k = 1;
                l++;
            }
        }
        if(k == 1)
        {
            printf("%s%d\n",a[i],l);
            l = 0;
            k = 0;
        }
        else
        {
            printf("OK\n");
        }
    }
    return 0;

}


#include<stdio.h>
#include<string.h>
char a[100000][500];
int main()
{
    int i,j,n,k = 0,l=0;
    scanf("%d",&n);
    getchar();
    for(i = 0; i < n; i++)
    {
        scanf("%s",a[i]);
        for(j = 0; j < i; j++)
        {
            if(strcmp(a[i],a[j]) == 0)
            {
                k = 1;
                l++;
            }
        }
        if(k == 1)
        {
            printf("%s%d\n",a[i],l);
            l = 0;
            k = 0;
        }
        else
        {
            printf("OK\n");
        }
        getchar();
    }
    return 0;

}


#include<stdio.h>
#include<string.h>
char a[100000][500],b[500];
int t[100000];
int main()
{
    int i,j,n,m=0;
    scanf("%d",&n);
    getchar();
    for(i = 0; i < n; i++)
    {
        scanf("%s",b);
        for(j = 0; j < m; j++)
        {
            if(strcmp(a[j],b) == 0)
            {
                break;
            }
        }
        if(j == m)
        {
            printf("OK\n");
            strcpy(a[m],b);
            m++;

        }
        else
        {
            t[j]++;
            printf("%s%d\n",b,t[j]);
        }
        getchar();
    }
    return 0;

}


#include<stdio.h>
#include<string.h>
char a[100000][500];
int main()
{
    int i,j,n,k = 0,l=0;
    char b[500];
    scanf("%d",&n);
    getchar();
    for(i = 0; i < n; i++)
    {
        scanf("%s",a[i]);
        getchar();
    }
    for(i = 0; i < n; i++)
    {
        for(j = 0; j < i; j++)
        {
            if(strcmp(a[i],a[j]) == 0)
            {
                k = 1;
                l++;
            }
        }
        if(k == 1)
        {
            strcpy(b,a[i]);
            printf("%s%d\n",b,l);
            l = 0;
            k = 0;
        }
        else
        {
            printf("OK\n");
        }
    }
    return 0;

}


#include<stdio.h>
#include<string.h>
int main()
{
    int i,j,n,k = 0,l=0,m,c;
    char a[1000][500],b[500];
    scanf("%d",&n);
    getchar();
    for(i = 0; i < n; i++)
    {
        scanf("%s",a[i]);
        getchar();
    }
    for(i = 0; i < n; i++)
    {
        for(j = 0; j < i; j++)
        {
            if(strcmp(a[i],a[j]) == 0)
            {
                k = 1;
                l++;
            }
        }
        if(k == 1)
        {
            strcpy(b,a[i]);
            m = strlen(b);
            for(c = 0; c < m; c++)
            {
                printf("%c",b[c]);
            }
            printf("%d\n",l);
            l = 0;
            k = 0;
        }
        else
        {
            printf("OK\n");
        }
    }
    return 0;

}


#include<stdio.h>
#include<string.h>
char a[100000][500];
int main()
{
    int i,j,n,k = 0,l=0,m,c;
    char b[500];
    scanf("%d",&n);
    getchar();
    for(i = 0; i < n; i++)
    {
        scanf("%s",a[i]);
        getchar();
    }
    for(i = 0; i < n; i++)
    {
        for(j = 0; j < i; j++)
        {
            if(strcmp(a[i],a[j]) == 0)
            {
                k = 1;
                l++;
            }
        }
        if(k == 1)
        {
            strcpy(b,a[i]);
            m = strlen(b);
            for(c = 0; c < m; c++)
            {
                printf("%c",b[c]);
            }
            printf("%d\n",l);
            l = 0;
            k = 0;
        }
        else
        {
            printf("OK\n");
        }
    }
    return 0;

}


#include <stdio.h>

int main(){
	int n;
	scanf("%d", &n);
	char names[n][33], s[33];
	int used=0, usetime[n];
	for(int i=0; i<n; ++i){
		int find=0;
		scanf("%s", &s);
		int same=1;
		for(int j=0; j<used; ++j){
			for(int m=0; m<33; ++m){
				if(names[j][m]=='\0' && s[m]=='\0'){
					break;
				}
				if(names[j][m]!=s[m] || names[j][m]=='\0' || s[m]=='\0'){
					same=0;
				//	printf("��%d�Ӥ��@��\n", m);
					break;
				}
				same=1;
			}
			if(same==1){
				printf("%s%d\n", names[j], usetime[j]);
				usetime[j]++;
				find=1;
				break;
			}
			else{
			//	printf("s= %s, names[%d]=%s\n", s, j, names[j]);
			}
		}
		if(find==0){
			names[used][0]=s[0];
			for(int k=1; s[k-1]!='\0'; ++k){
				names[used][k]=s[k];
			}
			usetime[used]=1;
			printf("OK\n");
			used++;
		}
	}
	return 0;
}


#include <stdio.h>

int main(){
	int n;
	scanf("%d", &n);
	char names[n][33], s[33];
	int used=0, usetime[n];
	for(int i=0; i<n; ++i){
		int find=0;
		scanf("%s", &s);
		int same=1;
		for(int j=0; j<used; ++j){
			for(int m=0; names[j][m]!='\0'; ++m){
				if(names[j][m]!=s[m]){
					same=0;
					break;
				}
				same=1;
			}
			if(same==1){
				printf("%s%d\n", names[j], usetime[j]);
				usetime[j]++;
				find=1;
				break;
			}
			else{
			//	printf("s= %s, names[%d]=%s\n", s, j, names[j]);
			}
		}
		if(find==0){
			names[used][0]=s[0];
			for(int k=1; s[k-1]!='\0'; ++k){
				names[used][k]=s[k];
			}
			usetime[used]=1;
			printf("OK\n");
			used++;
		}
	}
	return 0;
}


#include <stdio.h>

int main(){
	int n;
	scanf("%d", &n);
	char names[n][33], s[33];
	int used=0, usetime[n];
	for(int i=0; i<n; ++i){
		int find=0;
		scanf("%s", &s);
		int same=1;
		for(int j=0; j<used; ++j){
			for(int m=0; names[j][m]!='\0'; ++m){
				if(names[j][m]!=s[m]){
					same=0;
					break;
				}
			}
			if(same==1){
				printf("%s%d\n", names[j], usetime[j]);
				usetime[j]++;
				find=1;
				break;
			}
			else{
				printf("s= %s, names[%d]=%s\n", s, j, names[j]);
			}
		}
		if(find==0){
			names[used][0]=s[0];
			for(int k=1; s[k-1]!='\0'; ++k){
				names[used][k]=s[k];
			}
			usetime[used]=1;
			printf("OK\n");
			used++;
		}
	}
	return 0;
}


#include <stdio.h>

int main(){
	int n;
	scanf("%d", &n);
	char names[n][33], s[33];
	int used=0, usetime[n];
	for(int i=0; i<n; ++i){
		int find=0;
		scanf("%s", &s);
		int same=1;
		for(int j=0; j<used; ++j){
			for(int m=0; names[j][m]!='\0'; ++m){
				if(names[j][m]!=s[m]){
					same=0;
					break;
				}
			}
			if(same==1){
				printf("%s%d\n", names[j], usetime[j]);
				usetime[j]++;
				find=1;
				break;
			}
			else{
				//printf("s= %s, names[%d]=%s\n", s, j, names[j]);
			}
		}
		if(find==0){
			names[used][0]=s[0];
			for(int k=1; s[k-1]!='\0'; ++k){
				names[used][k]=s[k];
			}
			usetime[used]=1;
			printf("OK\n");
			used++;
		}
	}
	return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct {
    char name[33];
    int count;
} user;

typedef struct {
    char name[33];
    int index;
} cmp;

user inputs[100000]={{0}, 0};
cmp db[100000]={{0}, 0};

int myCompare (const void * a, const void * b ) {
    const cmp *pa = (const cmp*)a;
    const cmp *pb = (const cmp*)b;
    return strcmp(pa->name,pb->name);
}

int main() {
    int size=0;
    scanf("%d", &size);

    for(int i=0; i<size; i++){
        scanf("%s", inputs[i].name);
        memcpy(db[i].name, inputs[i].name, 33);
        db[i].index = i;
    }

    qsort(db, size, sizeof(cmp), myCompare);

    for(int n=1; n<size; n++){
        if(strcmp(db[n].name, db[n-1].name) == 0){
            inputs[db[n].index].count = inputs[db[n-1].index].count + 1;
        }
    }
    for(int n=0; n<size; n++){
        if(inputs[n].count != 0){
            printf("%s%d\n", inputs[n].name, inputs[n].count);
        }
        else {
            printf("OK\n");
        }
    }
    return 0;
}


#include <stdio.h>
#include <stdlib.h>

struct user {
    char *name;
    int count;
};

struct user* db = NULL;

int str_match(const char* src, const char* target){
    int i=0;

    while(src[i] != '\0' && i < 32){
        if(target[i] != src[i])
            return 0;
        i++;
    }
    if(target[i] == '\0' || (target[i] >= '0' && target[i] <= '9')){
        return 1;
    }
    else
        return 0;
}

int main(){
    int size=0;
    scanf("%d", &size);

    db = (struct user*) malloc(sizeof(struct user) * size);

    for(int i=0; i<size; i++){
        char *newName = (char*) calloc(sizeof(char), 32);
        scanf("%s", newName);
        db[i].name = newName;

        int count = 0;
        for (int n=i-1; n>=0 && db[i].count == 0; n--){
            db[i].count = str_match(newName, db[n].name) ? db[n].count + 1 : 0;
        }
        if (db[i].count == 0){
            printf("OK\n");
        }
        else {
            printf("%s%d\n", newName, db[i].count);
        }
    }

}