#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*) calloc(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);
        }
    }

}


#include <stdio.h>

char db[100000][32]={{0}};

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);

    for(int i=0; i<size; i++){
        char newName[32]={0};
        scanf("%s", newName);
        int columns;
        for(columns=0; columns<32 && newName[columns] != 0; columns++){
            db[i][columns] = newName[columns];
        }
        db[i][columns] = '\0';

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

}


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

char **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 = (char **) malloc(sizeof(char *) * size);

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

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

}


#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("OK\n");
        }
        else {
            printf("%s%d\n", inputs[n].name, inputs[n].count);
        }
    }
    return 0;
}


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

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

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

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

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);
        inputs[i].index = db[i].index = i;
    }

    qsort(db, size, sizeof(user), myCompare);
    for(int n=0;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;
        }
        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>

char **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 = (char **) malloc(sizeof(char *) * size);

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

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

}


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

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

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

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

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);
        inputs[i].index = db[i].index = i;
    }

    qsort(db, size, sizeof(user), myCompare);
    printf("OK\n");
    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;
        }
        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>
#include <string.h>

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

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

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

int myCompare (const void * a, const void * b ) {
    const cmp *pa = (const cmp*)a;
    const cmp *pb = (const cmp*)b;
    return strcmp(pb->name,pa->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=0; n<size; n++){
        int *item;
        item = (cmp*) bsearch(&inputs[n].name, db, size, sizeof(cmp), myCompare);
        const cmp *dbName = (const cmp*)item;
        if(item != NULL){
            if(n != dbName->index){
                inputs[dbName->index].count++;
                printf("%s%d\n", inputs[n].name, inputs[dbName->index].count);
            }
            else{
                printf("OK\n");
            }
        }
    }
    return 0;
}


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

char db[100000][32]={{0}};

int cmpfunc (char a[32], int index) {
    int flag = 0;
    int count = 0;
    for(int n=index-1; n>=0; n--){
        flag = 0;
        for(int i=0; i < 32; i++){
            if(a[i] != db[n][i]){
                flag = 1;
                i=33;
            }
        }
        if (flag == 0){
            count += 1;
        }
    }
    return count;
}

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

    for(int i=0; i<size; i++){
        char newName[32]={0};
        scanf("%s", newName);
        int columns;
        for(columns=0; columns<32 && newName[columns] != 0; columns++){
            db[i][columns] = newName[columns];
        }
        db[i][columns] = '\0';

        if(i == 0){
            printf("OK\n");
        }
        else {
            int count = 0;
            count = cmpfunc(newName, i);
            if (count == 0){
                printf("OK\n");
            }
            else {
                printf("%s%d\n", newName, count);
            }
        }
    }

}


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

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

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

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

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);
        inputs[i].index = db[i].index = i;
    }

    qsort(db, size, sizeof(user), 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>

char db[100000][32]={{0}};

int cmpfunc (char a[32], int index) {
    int flag = 0;
    int count = 0;
    for(int n=index-1; n>=0; n--){
        flag = 0;
        for(int i=0; i < 32; i++){
            if(a[i] != db[n][i]){
                flag = 1;
                i=33;
            }
        }
        if (flag == 0){
            count += 1;
        }
    }
    return count;
}

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

    for(int i=0; i<size; i++){
        char newName[32]={0};
        scanf("%s", newName);
        int columns;
        for(columns=0; columns<32 && newName[columns] != 0; columns++){
            db[i][columns] = newName[columns];
        }
        db[i][columns] = '\0';

        if(i == 0){
            printf("OK\n");
        }
        else {
            int count = 0;
            count = cmpfunc(newName, i);
            if (count == 0){
                printf("OK\n");
            }
            else {
                printf("%s%d\n", newName, count);
            }
        }
    }

}


#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 < 33){
        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*) calloc(sizeof(struct user), size);

    for(int i=0; i<size; i++){
        char *newName = (char*) calloc(sizeof(char), 33);
        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);
        }
    }

    for(int i=0; i < size; i++)
        free(db[i].name);

    free(db);

    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};
cmp db[100000]={0};
//const char *db[];

int myCompare (const void * a, const void * b ) {
    const cmp *pa = (const cmp*)a;
    const cmp *pb = (const cmp*)b;
//    const char *pa = (const char*)a;
//    const char *pb = (const char*)b;
    return strcmp(pb->name,pa->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;
    }

    printf("\n");
    for(int n=0; n<size; n++){
        printf("name: %s, index: %d\n", db[n].name, db[n].index);
    }

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

    printf("\n");
    for(int n=0; n<size; n++){
        printf("name: %s, index: %d\n", db[n].name, db[n].index);
    }

    printf("\n");
    for(int n=0; n<size; n++){
        int *item;
        item = (cmp*) bsearch(&inputs[n].name, db, size, sizeof(cmp), myCompare);
        const cmp *dbName = (const cmp*)item;
        if(item != NULL){
            if(n != dbName->index){
                inputs[dbName->index].count++;
                printf("%s%d\n", inputs[n].name, inputs[dbName->index].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*) calloc(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);
        }
    }

    for(int i=0; i < size; i++)
        free(db[i].name);

    free(db);

    return 0;
}


struct map_element {
    char name[33];
    int value;
};

struct map_element * init_map_element(char *name, int value);
struct map_element ** init_map(size_t count);
struct map_element * init_map_contents(size_t count);
void add_to_map(struct map_element *me);
void add_to_map_contents(char *name, int value);
void free_map_contents(void);
size_t count_of_elements(void);

static struct map_element **pmap;
static size_t count = 0;

struct map_element *init_map_element(char *name, int value) {
    struct map_element *temp = (struct map_element *) malloc(sizeof(struct map_element));
    strcpy(temp->name, name);
    temp->value = value;
    return temp;
}

struct map_element ** init_map(size_t count) {
    pmap = (struct map_element **) malloc(count * sizeof(struct map_element *));
    count = 0;
    return pmap;
}

void add_to_map(struct map_element *me) {
    pmap[count++] = me;
}

// MARK: map contents implementation
struct map_element *pmap_contents;
static size_t count_contents = 0;

struct map_element * init_map_contents(size_t count) {
    pmap_contents = (struct map_element *) calloc(count, sizeof(struct map_element));
    return pmap_contents;
}

void add_to_map_contents(char *name, int value) {
    struct map_element *temp = &pmap_contents[count_contents];
    strcpy(temp->name, name);
    temp->value = value;
    count_contents++;
}
void free_map_contents() {
    free(pmap_contents);
}

size_t count_of_elements() {
    return count_contents;
}

struct map_element *map;

int check(char *temp) {
    for (int i = 0; i < count_of_elements(); i++) {
        if (strcmp(temp, map[i].name) == 0) {
            map[i].value++;
            return 0;
        }
    }
    return 1;
}

int main() {
    size_t n = 0;
    scanf("%lu", &n);
    map = init_map_contents(n);
    char temp[33];
    for (int i = 0; i < n; i++) {
        scanf("%s", temp);
        if (check(temp)) {
            add_to_map_contents(temp, 0);
            puts("OK");
        }
        else {
            int m = 0;
            for (int i = 0; i < count_of_elements(); i++) {
                if (strcmp(temp, map[i].name) == 0)
                    m = map[i].value;
            }
            printf("%s%d\n", temp, m);
        }
    }
    free_map_contents();
    return 0;
}


//
//  registration.c
//  Dynamic Array
//
//  Created by Melody Hamedani on 1/9/20.
//  Copyright © 2020 Melody Hamedani. All rights reserved.
//

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

struct map_element {
    char name[33];
    int value;
};

struct map_element *pmap_contents;
static size_t count_contents = 0;

struct map_element * init_map_contents(size_t count) {
    pmap_contents = (struct map_element *) calloc(count, sizeof(struct map_element));
    return pmap_contents;
}

void add_to_map_contents(char *name, int value) {
    struct map_element *temp = &pmap_contents[count_contents];
    strcpy(temp->name, name);
    temp->value = value;
    count_contents++;
}
void free_map_contents() {
    free(pmap_contents);
}

size_t count_of_elements() {
    return count_contents;
}

struct map_element *map;

int check(char *temp) {
    for (int i = 0; i < count_of_elements(); i++) {
        if (strcmp(temp, map[i].name) == 0) {
            map[i].value++;
            return 0;
        }
    }
    return 1;
}

int main() {
    size_t n = 0;
    scanf("%lu", &n);
    map = init_map_contents(n);
    char temp[33];
    for (int i = 0; i < n; i++) {
        int j = 0;
        scanf("%s", temp);
        for (j = 0; j < count_of_elements(); j++) {
            if (strcmp(temp, map[j].name) == 0) {
                map[j].value++;
                printf("%s%d\n", temp, map[j].value);
                break;
            }
        }
        if (j == count_of_elements()) {
            add_to_map_contents(temp, 0);
            puts("OK");
        }

    }
    free_map_contents();
    return 0;
}


//
//  registration.c
//  Dynamic Array
//
//  Created by Melody Hamedani on 1/9/20.
//  Copyright © 2020 Melody Hamedani. All rights reserved.
//

#include <stdio.h>
#include <string.h>
#include "map.h"

struct map_element *map;

int check(char *temp) {
    for (int i = 0; i < count_of_elements(); i++) {
        if (strcmp(temp, map[i].name) == 0) {
            map[i].value++;
            return 0;
        }
    }
    return 1;
}

int main() {
    size_t n = 0;
    scanf("%lu", &n);
    map = init_map_contents(n);
    char temp[33];
    for (int i = 0; i < n; i++) {
        scanf("%s", temp);
        if (check(temp)) {
            add_to_map_contents(temp, 0);
            puts("OK");
        }
        else {
            int m = 0;
            for (int i = 0; i < count_of_elements(); i++) {
                if (strcmp(temp, map[i].name) == 0)
                    m = map[i].value;
            }
            printf("%s%d\n", temp, m);
        }
    }
    free_map_contents();
    return 0;
}


//
//  registration.c
//  Dynamic Array
//
//  Created by Melody Hamedani on 1/9/20.
//  Copyright © 2020 Melody Hamedani. All rights reserved.
//

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

struct map_element {
    char name[33];
    int value;
};

struct map_element *pmap_contents;
static size_t count_contents = 0;

struct map_element * init_map_contents(size_t count) {
    pmap_contents = (struct map_element *) calloc(count, sizeof(struct map_element));
    return pmap_contents;
}

void add_to_map_contents(char *name, int value) {
    struct map_element *temp = &pmap_contents[count_contents];
    strcpy(temp->name, name);
    temp->value = value;
    count_contents++;
}
void free_map_contents() {
    free(pmap_contents);
}

size_t count_of_elements() {
    return count_contents;
}

struct map_element *map;

int check(char *temp) {
    for (int i = 0; i < count_of_elements(); i++) {
        if (strcmp(temp, map[i].name) == 0) {
            map[i].value++;
            return 0;
        }
    }
    return 1;
}

int main() {
    size_t n = 0;
    scanf("%lu", &n);
    map = init_map_contents(n);
    char temp[33];
    for (int i = 0; i < n; i++) {
        scanf("%s", temp);
        if (check(temp)) {
            add_to_map_contents(temp, 0);
            puts("OK");
        }
        else {
            int m = 0;
            for (int i = 0; i < count_of_elements(); i++) {
                if (strcmp(temp, map[i].name) == 0)
                    m = map[i].value;
            }
            printf("%s%d\n", temp, m);
        }
    }
    free_map_contents();
    return 0;
}


//
//  registration.c
//  Dynamic Array
//
//  Created by Melody Hamedani on 1/9/20.
//  Copyright © 2020 Melody Hamedani. All rights reserved.
//

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

struct map_element {
    char name[33];
    int value;
};

struct map_element *pmap_contents;
static size_t count_contents = 0;

struct map_element * init_map_contents(size_t count) {
    pmap_contents = (struct map_element *) calloc(count, sizeof(struct map_element));
    return pmap_contents;
}

void add_to_map_contents(char *name, int value) {
    struct map_element *temp = &pmap_contents[count_contents];
    strcpy(temp->name, name);
    temp->value = value;
    count_contents++;
}
void free_map_contents() {
    free(pmap_contents);
}

size_t count_of_elements() {
    return count_contents;
}

struct map_element *map;

int check(char *temp) {
    for (int i = 0; i < count_of_elements(); i++) {
        if (strcmp(temp, map[i].name) == 0) {
            map[i].value++;
            return 0;
        }
    }
    return 1;
}

int main() {
    size_t n = 0;
    scanf("%lu", &n);
    map = init_map_contents(n);
    char temp[33];
    scanf("%s", temp);
    add_to_map_contents(temp, 0);
    puts("OK");
    for (int i = 1; i < n; i++) {
        scanf("%s", temp);
        for (int j = 0; j < count_of_elements(); j++) {
            if (strcmp(temp, map[j].name) == 0) {
                map[j].value++;
                printf("%s%d\n", temp, map[j].value);
                break;
            }
            else {
                add_to_map_contents(temp, 0);
                puts("OK");
                break;
            }
        }
    }
    free_map_contents();
    return 0;
}


# include <stdio.h>
# include <string.h>
# include <stdbool.h>
#define MAXN 100000

struct Request{

char name[33];
int count;

};

int main(){

   int n;

   scanf("%d",&n);

   if(n> MAXN)
   {
        printf("Exceeded ");
        return 0;
   }

   struct Request iR[n];
   char tempReq[MAXN][33]={{0}};

   for(int i=0; i<n; i++){

   scanf("%s",tempReq[i]);

   }
   // Run a loop to check if name in array
   // If not present insert
   // if present increment counter by 1 and print
   int t=0;
   bool notOk = false;
   for( int i=0;i<n;i++)
   {
        notOk = false;

        for(int j=0;j<t;j++)
        {

                if ( strcmp(tempReq[i],iR[j].name) == 0 )
                {
                        iR[j].count++;
                        printf("%s%d\n",tempReq[i],iR[j].count);
                        notOk = true;
                        continue;
                }

        }
        if(!notOk)
        {
                strcpy(iR[t].name,tempReq[i]);
                iR[t].count =0;
                printf("OK\n");
                t++;

        }
   }

   }


# include <stdio.h>
# include <string.h>
# include <ctype.h>
# include <stdint.h>
#define MAXN 100000

struct Request{

char uname[33];
int ucount;

};

static size_t hash(const char *cp);
static void add_user(const char* name);
static struct Request *find_user(const char* name);

struct Request user_list[MAXN];

int main(){

   int n;

   scanf("%d",&n);

   if(n> MAXN)
   {
        printf("Exceeded ");
        return 0;
   }
   char tempReq[33];

   for(int i=0; i<n; i++){

   scanf("%s",tempReq);

   struct Request *user = find_user(tempReq);

   if(user)
   {
           printf("%s%d\n",user->uname,user->ucount);
           user->ucount++;
   }
   else
   {
        add_user(tempReq);
        printf("OK\n");

   }
 }

 }

static size_t hash(const char *cp){

 unsigned size_t hash = 14695981039346656037;
 while(*cp){

        hash= 1099511628211 * hash ^ (unsigned char)*cp++;

 }
static void add_user(const char* name)
{
        size_t hash_value = hash(name);
        if(user_list[hash_value].ucount !=0 && strcmp(user_list[hash_value].uname,name)!=0)
        {
                do{
                        hash_value = (hash_value+1)% MAXN;
                }while(user_list[hash_value].ucount !=0);

        }

        strcpy(user_list[hash_value].uname, name);
        user_list[hash_value].ucount++;

}

static struct Request *find_user(const char* name){

        size_t hash_value= hash(name);
        if(user_list[hash_value].ucount ==0 && strlen(user_list[hash_value].uname)==0)
                return NULL;

        while(user_list[hash_value].ucount !=0 && strlen(user_list[hash_value].uname)!=0)
        {
                // strcmp returns 0 only if equal. Negate to pass inside if
                if( !strcmp(user_list[hash_value].uname, name))
                        return &user_list[hash_value];
                hash_value= (hash_value+1)%MAXN;

        }
        return NULL;
}


# include <string.h>
# include <stdbool.h>
#define MAXN 100000

struct Request{

char name[32];
int count;

};

int main(){

int n;

scanf("%d",&n);

if(n> MAXN)
{
        printf("Exceeded ");
        return 0;
}

struct Request iR[n];
char tempReq[n][32];

for(int i=0; i<n; i++){

scanf("%s",tempReq[i]);

}
// Run a loop to check if name in array
// If not present insert
// if present increment counter by 1 and print
int t=0;
bool notOk = false;
for( int i=0;i<n;i++)
{

        for(int j=0;j<t;j++)
        {

                if ( strcmp(tempReq[i],iR[j].name) == 0 )
                {
                        iR[j].count++;
                        printf("%s%d\n",tempReq[i],iR[j].count);
                        notOk = true;
                        continue;
                }

        }
        if(!notOk)
        {
                strcpy(iR[t].name,tempReq[i]);
                iR[t].count =0;
                printf("OK\n");
                t++;
                notOk = false;
        }
}

}


# include <stdio.h>
# include <string.h>
# include <stdbool.h>
#define MAXN 100000

struct Request{

char name[32];
int count;

};

int main(){

int n;

scanf("%d",&n);

if(n> MAXN)
{
        printf("Exceeded ");
        return 0;
}

struct Request iR[n];
char tempReq[n][32];

for(int i=0; i<n; i++){

scanf("%s",tempReq[i]);

}
// Run a loop to check if name in array
// If not present insert
// if present increment counter by 1 and print
int t=0;
bool notOk = false;
for( int i=0;i<n;i++)
{

        for(int j=0;j<t;j++)
        {

                if ( strcmp(tempReq[i],iR[j].name) == 0 )
                {
                        char printOut[32];
                        iR[j].count++;
                        sprintf(printOut,"%s%d",tempReq[i],iR[j].count);
                        printf("%s\n",printOut);
                        notOk = true;
                        continue;
                }

        }
        if(!notOk)
        {
                strcpy(iR[t].name,tempReq[i]);
                iR[t].count =0;
                printf("OK\n");
                t++;
                notOk = false;
        }
}

}


# include <stdio.h>
# include <string.h>
# include <ctype.h>
# include <stdint.h>
#define MAXN 100000

struct Request{

char uname[33];
int ucount;

};

static size_t hash(const char *cp);
static void add_user(const char* name);
static struct Request *find_user(const char* name);

struct Request user_list[MAXN];

int main(){

   int n;

   scanf("%d",&n);

   if(n> MAXN)
   {
        printf("Exceeded ");
        return 0;
   }
   char tempReq[33];

   for(int i=0; i<n; i++){

   scanf("%s",tempReq);

   struct Request *user = find_user(tempReq);

   if(user)
   {
           printf("%s%d\n",user->uname,user->ucount);
           user->ucount++;
   }
   else
   {
        add_user(tempReq);
        printf("OK\n");

   }
 }

 }

static size_t hash(const char *cp){

 size_t hash = 14695981039346656037;
 while(*cp){

        hash= 1099511628211 * hash ^ (unsigned char)*cp++;

 }
static void add_user(const char* name)
{
        size_t hash_value = hash(name);
        if(user_list[hash_value].ucount !=0 && strcmp(user_list[hash_value].uname,name)!=0)
        {
                do{
                        hash_value = (hash_value+1)% MAXN;
                }while(user_list[hash_value].ucount !=0);

        }

        strcpy(user_list[hash_value].uname, name);
        user_list[hash_value].ucount++;

}

static struct Request *find_user(const char* name){

        size_t hash_value= hash(name);
        if(user_list[hash_value].ucount ==0 && strlen(user_list[hash_value].uname)==0)
                return NULL;

        while(user_list[hash_value].ucount !=0 && strlen(user_list[hash_value].uname)!=0)
        {
                // strcmp returns 0 only if equal. Negate to pass inside if
                if( !strcmp(user_list[hash_value].uname, name))
                        return &user_list[hash_value];
                hash_value= (hash_value+1)%MAXN;

        }
        return NULL;
}


# include <string.h>
# include <stdbool.h>
#define MAXN 100000

struct Request{

char name[32];
int count;

};

int main(){

int n;

scanf("%d",&n);

if(n> MAXN)
{
        printf("Exceeded ");
        return 0;
}

struct Request iR[n];
char tempReq[n][32];

for(int i=0; i<n; i++){

scanf("%s",tempReq[i]);

}
// Run a loop to check if name in array
// If not present insert
// if present increment counter by 1 and print
int t=0;
bool notOk = false;
for( int i=0;i<n;i++)
{

        for(int j=0;j<t;j++)
        {

                if ( strcmp(tempReq[i],iR[j].name) == 0 )
                {
                        iR[j].count++;
                        printf("%s%d\n",tempReq[i],iR[j].count);
                        notOk = true;
                        break;
                }

        }
        if(!notOk)
        {
                strcpy(iR[t].name,tempReq[i]);
                iR[t].count =0;
                printf("OK\n");
                t++;
                notOk = false;
        }
}

}


# include <stdio.h>
# include <string.h>
# include <stdbool.h>
#define MAXN 100000

struct Request{

char name[32];
int count;

};

int main(){

   int n;

   scanf("%d",&n);

   if(n> MAXN)
   {
        printf("Exceeded ");
        return 0;
   }

   struct Request iR[n];
   char tempReq[MAXN][32]={{0}};

   for(int i=0; i<n; i++){

   scanf("%s",tempReq[i]);

   }
   // Run a loop to check if name in array
   // If not present insert
   // if present increment counter by 1 and print
   int t=0;
   bool notOk = false;
   for( int i=0;i<n;i++)
   {
        notOk = false;

        for(int j=0;j<t;j++)
        {

                if ( strcmp(tempReq[i],iR[j].name) == 0 )
                {
                        char printOut[32];
                        iR[j].count++;
                        sprintf(printOut,"%s%d",tempReq[i],iR[j].count);
                           printf("%s\n",printOut);
                        notOk = true;
                        continue;
                }

        }
        if(!notOk)
        {
                strcpy(iR[t].name,tempReq[i]);
                iR[t].count =0;
                printf("OK\n");
                t++;
       }
   }

   }


#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdint.h>
#define MAXN 100000

struct Request{

char uname[33];
int ucount;

};

static size_t hash(const char *cp);
static void add_user(const char* name);
static struct Request *find_user(const char* name);

struct Request user_list[MAXN];

int main(){

   int n;

   scanf("%d",&n);

   if(n> MAXN)
   {
        printf("Exceeded ");
        return 0;
   }
   char tempReq[33];

   for(int i=0; i<n; i++){

   scanf("%s",tempReq);

struct Request *user = find_user(tempReq);

   if(user)
   {
           printf("%s%d\n",user->uname,user->ucount);
           user->ucount++;
   }
   else
   {
        add_user(tempReq);
        printf("OK\n");

   }
 }

 }

static size_t hash(const char *cp){

 size_t hash = 14695981039346656037ull;
 while(*cp){

        hash= 1099511628211 * hash ^ (unsigned char)*cp++;

 }

 return hash % MAXN;

}

static void add_user(const char* name)
{
        size_t hash_value = hash(name);
        if(user_list[hash_value].ucount !=0 && strcmp(user_list[hash_value].uname,name)!=0)
        {
                do{
                        hash_value = (hash_value+1)% MAXN;
                }while(user_list[hash_value].ucount !=0);

        }

        strcpy(user_list[hash_value].uname, name);
        user_list[hash_value].ucount++;

}

static struct Request *find_user(const char* name){

        size_t hash_value= hash(name);
        if(user_list[hash_value].ucount ==0 && strlen(user_list[hash_value].uname)==0)
                return NULL;

        while(user_list[hash_value].ucount !=0 && strlen(user_list[hash_value].uname)!=0)
        {
                // strcmp returns 0 only if equal. Negate to pass inside if
                if( !strcmp(user_list[hash_value].uname, name))
                        return &user_list[hash_value];
                 hash_value= (hash_value+1)%MAXN;

        }
        return NULL;
}


# include <stdio.h>
# include <string.h>
# include <stdbool.h>
#define MAXN 100000

struct Request{

char name[32];
int count;

};

int main(){

   int n;

   scanf("%d",&n);

   if(n> MAXN)
   {
        printf("Exceeded ");
        return 0;
   }

   struct Request iR[n];
   char tempReq[MAXN][32]={{0}};

   for(int i=0; i<n; i++){

   scanf("%s",tempReq[i]);

   }
   // Run a loop to check if name in array
   // If not present insert
   // if present increment counter by 1 and print
   int t=0;
   bool notOk = false;
   for( int i=0;i<n;i++)
   {

        for(int j=0;j<t;j++)
        {

                if ( strcmp(tempReq[i],iR[j].name) == 0 )
                {
                        char printOut[32];
                        iR[j].count++;
                        sprintf(printOut,"%s%d",tempReq[i],iR[j].count);
                        printf("Line1\n");
                        printf("%s\n",printOut);
                        printf("Line2 \n");
                        notOk = true;
                        printf("Line3 \n");
                        continue;
                }

        }
        if(!notOk)
        {
                strcpy(iR[t].name,tempReq[i]);
                iR[t].count =0;
                printf("OK\n");
                t++;
                notOk = false;
        }
}
}


# include <stdio.h>
# include <string.h>
# include <stdbool.h>
#define MAXN 100000

struct Request{

char name[32];
int count;

};

int main(){

   int n;

   scanf("%d",&n);

   if(n> MAXN)
   {
        printf("Exceeded ");
        return 0;
   }

   struct Request iR[n];
   char tempReq[MAXN][32]={{0}};

   for(int i=0; i<n; i++){

   scanf("%s",tempReq[i]);

   }
   // Run a loop to check if name in array
   // If not present insert
   // if present increment counter by 1 and print
   int t=0;
   bool notOk = false;
   for( int i=0;i<n;i++)
   {

       notOk = false;

        for(int j=0;j<t;j++)
        {

                if ( strcmp(tempReq[i],iR[j].name) == 0 )
                {
                        char printOut[32];
                        iR[j].count++;
                        sprintf(printOut,"%s%d",tempReq[i],iR[j].count);
                        printf("Line1\n");
                        printf("%s\n",printOut);
                        printf("Line2 \n");
                        notOk = true;
                        printf("Line3 \n");
                        continue;
                }

        }
        if(!notOk)
        {
                strcpy(iR[t].name,tempReq[i]);
                iR[t].count =0;
                printf("OK\n");
                t++;

        }
}
}


# include <string.h>
# include <stdbool.h>
#define MAXN 100000

struct Request{

char name[32];
int count;

};

int main(){

int n;

scanf("%d",&n);

if(n> MAXN)
{
        printf("Exceeded ");
        return 0;
}

struct Request iR[n];
char tempReq[n][32];

for(int i=0; i<n; i++){

scanf("%s",tempReq[i]);

}
// Run a loop to check if name in array
// If not present insert
// if present increment counter by 1 and print
int t=0;
bool notOk = false;
for( int i=0;i<n;i++)
{

        for(int j=0;j<n;j++)
        {

                if ( strcmp(tempReq[i],iR[j].name) == 0 )
                {
                        iR[j].count++;
                        printf("%s%d\n",tempReq[i],iR[j].count);
                        notOk = true;
                        break;
                }

}
strcpy(iR[t].name,tempReq[i]);
iR[t].count =0;
if(!notOk)
        printf("OK\n");
t++;
}

}


# include <stdio.h>
# include <string.h>
# include <stdbool.h>
#define MAXN 100000

struct Request{

char name[32];
int count;

};

int main(){

   int n;

   scanf("%d",&n);

   if(n> MAXN)
   {
        printf("Exceeded ");
        return 0;
   }

   struct Request iR[n];
   char tempReq[MAXN][32]={{0}};

   for(int i=0; i<n; i++){

   scanf("%s",tempReq[i]);

   }
   // Run a loop to check if name in array
   // If not present insert
   // if present increment counter by 1 and print
   int t=0;
   bool notOk = false;
   for( int i=0;i<n;i++)
   {

        for(int j=0;j<t;j++)
        {

                if ( strcmp(tempReq[i],iR[j].name) == 0 )
                {
                        char printOut[32];
                        iR[j].count++;
                        sprintf(printOut,"%s%d",tempReq[i],iR[j].count);
                           printf("%s\n",printOut);
                        notOk = true;
                        continue;
                }

        }
        if(!notOk)
        {
                strcpy(iR[t].name,tempReq[i]);
                iR[t].count =0;
                printf("OK\n");
                t++;
                notOk = false;
        }
}

}


# include <stdio.h>
# include <string.h>
# include <stdbool.h>
#define MAXN 100000

struct Request{

char name[32];
int count;

};

int main(){

   int n;

   scanf("%d",&n);

   if(n> MAXN)
   {
        printf("Exceeded ");
        return 0;
   }

   struct Request iR[n];
   char tempReq[MAXN][32]={{0}};

   for(int i=0; i<n; i++){

   scanf("%s",tempReq[i]);

   }
   // Run a loop to check if name in array
   // If not present insert
   // if present increment counter by 1 and print
   int t=0;
   bool notOk = false;
   for( int i=0;i<n;i++)
   {

        for(int j=0;j<t;j++)
        {

                if ( strcmp(tempReq[i],iR[j].name) == 0 )
                {
                        char printOut[32];
                        iR[j].count++;
                        sprintf(printOut,"%s%d",tempReq[i],iR[j].count);
                           printf("%s\n",printOut);
                        notOk = true;
                        continue;
                }

        }
        if(!notOk)
        {
                strcpy(iR[t].name,tempReq[i]);
                iR[t].count =0;
                printf("OK\n");
                t++;
                notOk = false;
        }
   }

   }


struct Request{

char name[32];
int count;

};

int main(){

   int n;

   scanf("%d",&n);

   if(n> MAXN)
   {
        printf("Exceeded ");
        return 0;
   }

   struct Request iR[n];
   char tempReq[MAXN][32]={{0}};

   for(int i=0; i<n; i++){

   scanf("%s",tempReq[i]);

   }
   // Run a loop to check if name in array
   // If not present insert
   // if present increment counter by 1 and print
   int t=0;
   bool notOk = false;
   for( int i=0;i<n;i++)
   {

        for(int j=0;j<t;j++)
        {

                if ( strcmp(tempReq[i],iR[j].name) == 0 )
                {
                        char printOut[32];
                        iR[j].count++;
                        sprintf(printOut,"%s%d",tempReq[i],iR[j].count);
                        printf("This line 1");
                        printf("%s\n",printOut);
                        printf("This line 2");
                        notOk = true;
                         printf("This line 3");
                        continue;
                }

        }
        if(!notOk)
        {
                strcpy(iR[t].name,tempReq[i]);
                iR[t].count =0;
                printf("OK\n");
                t++;
                notOk = false;
        }
   }

   }


# include <stdio.h>
# include <string.h>
# include <stdbool.h>
#define MAXN 100000

struct Request{

char name[32];
int count;

};

int main(){

   int n;

   scanf("%d",&n);

   if(n> MAXN)
   {
        printf("Exceeded ");
        return 0;
   }

   struct Request iR[n];
   char tempReq[MAXN][32]={{0}};

   for(int i=0; i<n; i++){

   scanf("%s",tempReq[i]);

   }
   // Run a loop to check if name in array
   // If not present insert
   // if present increment counter by 1 and print
   int t=0;
   bool notOk = false;
   for( int i=0;i<n;i++)
   {

        for(int j=0;j<t;j++)
        {

                if ( strcmp(tempReq[i],iR[j].name) == 0 )
                {
                        char printOut[32];
                        iR[j].count++;
                        sprintf(printOut,"%s%d",tempReq[i],iR[j].count);
                        printf("Line1\n")
                        printf("%s\n",printOut);
                        printf("Line2 \n");
                        notOk = true;
                        printf("Line3 \n");
                        continue;
                }

        }
        if(!notOk)
        {
                strcpy(iR[t].name,tempReq[i]);
                iR[t].count =0;
                printf("OK\n");
                t++;
                notOk = false;
        }
}
}


    #include<stdio.h>
    #include<string.h>
    int g[100004];
    char c[100004][33],b[40];
    int main()
    {
        int i,l=0,k;
        scanf("%d",&k);
        while(k--){
            scanf("%s",&b);
            for(i=0;i<l;i++){
                if(strcmp(c[i],b)==0){
                    break;
                }
            }
            if(i==l){
                printf("OK\n");
                strcpy(c[l++],b);
            }
            else{
                printf("%s%d\n",b,++g[i]);
            }
        }
        return 0;
    }


#include<stdio.h>
#include<string.h>
int main()
{
    int n,a,x,z,y=0;
    scanf("%d",&n);
    char s[n+1][33];
    int g[n+1];

    for(x=0;x<n;x++)
    {
        scanf("%s",&s[x]);
        a=0;
        for(y=0;y<x;y++)
        {
            if(strcmp(s[x],s[y])==0)
            a++;
        }
        if(a==0)
        {
            printf("OK\n");
        }
        else
        {
            printf("%s%d\n",s[x],a);
        }
    }
    return 0;
}


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

struct ogrenci{

	char isim[33];
	int sayac;
};
struct ogrenci kayit[10000];
int toplam=0;

int kontrol(int n){
	char yeni[33];
	for(int i=0;i<n;i++)
	{
		scanf("%s",&yeni);

		for(int j=0;j<toplam+1;j++)
		{
			if(strcmp(yeni,kayit[j].isim)==0)
			{
				kayit[j].sayac++;
				printf("%s%d\n",kayit[j].isim,kayit[j].sayac);
				break;
			}
			else if(j==toplam)
			{
				kayit[toplam].sayac=0;
				strcpy(kayit[toplam].isim,yeni);
				toplam++;
				printf("OK\n");
				break;
			}
		}
	}

}

int main(){

	int n;
	scanf("%d",&n);
	kontrol(n);

	return 0;
}


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

struct ogrenci{

	char isim[33];
	int sayac;
};

int main(){

	int n;
	int toplam=0;
	scanf("%d",&n);
	char yeni[33];
	struct ogrenci kayit[10000];
	for(int i=0;i<n;i++)
	{
		scanf("%s",&yeni);

		for(int j=0;j<toplam+1;j++)
		{
			if(strcmp(yeni,kayit[j].isim)==0)
			{
				kayit[j].sayac++;
				printf("%s%d\n",kayit[j].isim,kayit[j].sayac);
				break;
			}
			else if(j==toplam)
			{
				kayit[toplam].sayac=0;
				strcpy(kayit[toplam].isim,yeni);
				toplam++;
				printf("OK\n");
				break;
			}
		}
	}

	return 0;
}


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

struct ogrenci{

	char isim[33];
	int sayac;
};

int toplam=0;

int main(){

	int n;
	scanf("%d",&n);
	char yeni[33];
	struct ogrenci kayit[10000];
	for(int i=0;i<n;i++)
	{
		scanf("%s",&yeni);

		for(int j=0;j<toplam+1;j++)
		{
			if(strcmp(yeni,kayit[j].isim)==0)
			{
				kayit[j].sayac++;
				printf("%s%d\n",kayit[j].isim,kayit[j].sayac);
				break;
			}
			else if(j==toplam)
			{
				kayit[toplam].sayac=0;
				strcpy(kayit[toplam].isim,yeni);
				toplam++;
				printf("OK\n");
				break;
			}
		}
	}

	return 0;
}


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

struct kayit{
	char isim[33];
	int numara=0;
};

int main(){

	int n;
	char kayit[33];
	scanf("%d",&n);
	struct kayit yeni[n];
	for(int i=0;i<n;i++)
	{
		scanf("%s",&kayit);
		for(int j=0;j<=i;j++)
		{
			if(strcmp(kayit,yeni[j].isim)==0)
			{
				yeni[j].numara++;
				printf("%s%d\n",kayit,yeni[j].numara);
				break;
			}
			if(j==i)
			{
				printf("OK\n");
				strcpy(yeni[i].isim,kayit);
			}
		}

	}

	return 0;
}


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

struct ogrenci{

	char isim[33];
	int sayac;
};

int toplam=0;

int kontrol(int n){
	char yeni[33];
	struct ogrenci kayit[10000];
	for(int i=0;i<n;i++)
	{
		scanf("%s",&yeni);

		for(int j=0;j<toplam+1;j++)
		{
			if(strcmp(yeni,kayit[j].isim)==0)
			{
				kayit[j].sayac++;
				printf("%s%d\n",kayit[j].isim,kayit[j].sayac);
				break;
			}
			else if(j==toplam)
			{
				kayit[toplam].sayac=0;
				strcpy(kayit[toplam].isim,yeni);
				toplam++;
				printf("OK\n");
				break;
			}
		}
	}

}

int main(){

	int n;
	scanf("%d",&n);
	kontrol(n);

	return 0;
}


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

struct ogrenci{

	char isim[33];
	int sayac;
};

int main(){

	int n;
	int toplam=0;
	scanf("%d",&n);
	char yeni[33];
	struct ogrenci kayit[n];
	for(int i=0;i<n;i++)
	{
		scanf("%s",&yeni);

		for(int j=0;j<toplam+1;j++)
		{
			if(strcmp(yeni,kayit[j].isim)==0)
			{
				kayit[j].sayac++;
				printf("%s%d\n",kayit[j].isim,kayit[j].sayac);
				break;
			}
			else if(j==toplam)
			{
				kayit[toplam].sayac=0;
				strcpy(kayit[toplam].isim,yeni);
				toplam++;
				printf("OK\n");
				break;
			}
		}
	}

	return 0;
}


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

struct kayit{
	char isim[33];
	int numara;
};

int main(){

	int n;
	char kayit[33];
	scanf("%d",&n);
	struct kayit yeni[n];
	for(int i=0;i<n;i++)
	{
		yeni[i].numara=0;
		scanf("%s",&kayit);
		for(int j=0;j<=i;j++)
		{
			if(strcmp(kayit,yeni[j].isim)==0)
			{
				yeni[j].numara++;
				printf("%s%d\n",kayit,yeni[j].numara);
				break;
			}
			if(j==i)
			{
				printf("OK\n");
				strcpy(yeni[i].isim,kayit);
			}
		}

	}

	return 0;
}


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

struct ogrenci{

	char isim[33];
	int sayac;
};
struct ogrenci kayit[10000];
unsigned int toplam=0;

int kontrol(int n){
	char yeni[33];
	for(int i=0;i<n;i++)
	{
		scanf("%s",&yeni);

		for(int j=0;j<toplam+1;j++)
		{
			if(strcmp(yeni,kayit[j].isim)==0)
			{
				kayit[j].sayac++;
				printf("%s%d\n",kayit[j].isim,kayit[j].sayac);
				break;
			}
			else if(j==toplam)
			{
				kayit[toplam].sayac=0;
				strcpy(kayit[toplam].isim,yeni);
				toplam++;
				printf("OK\n");
				break;
			}
		}
	}

}

int main(){

	int n;
	scanf("%d",&n);
	kontrol(n);

	return 0;
}


#include <stdio.h>

#define HASH_SIZE 1000
#define HASH_LEN 400
#define HASH_VAL 17

static int data[HASH_SIZE][HASH_LEN];
static int length[HASH_SIZE];
static char s_index[HASH_SIZE][HASH_LEN]; // index 저장
static char s_data[HASH_SIZE][HASH_LEN]; // 문자열 저장
static int idx = 0;
static int N;
static char str[32];

static int getHashKey(char* str, int count) {

    int key = 0;
    for (int i = 0; i < count; i++)
    {
        key = (key * HASH_VAL) + str[i];
    }

    if(key < 0) key = -key; // 음수면 양수로

    return key % HASH_SIZE;
}

static int cp(int temp, int count) {

    int cnt = 0;

    for (int i = 0; i < HASH_LEN; i++)
    {
        if(!s_data[temp][i]) break;
        else cnt++;
    }

    if(cnt < count) return count;
    else return cnt;

}

static int checking(char* str, int count, int key) {

    int len = length[key];

    if(len != 0) { // 해당 key 값에 데이터가 있음

        for (int i = 0; i < len; i++)
        {
            int temp = s_index[key][i];

            int check_size = cp(temp, count);
            int tf = 1;

            for (int j = 0; j < check_size; j++)
            {
                if(str[j] != s_data[temp][j]) {
                    tf = 0;
                    break;
                }
            }

            if(tf == 1) {
                data[key][i]++;
                return data[key][i];
            }

        }

    }

    // 없으면
    s_index[key][length[key]++] = idx;

    for (int i = 0; i < count; i++)
    {
        s_data[idx][i] = str[i];
    }
    idx++;

    return -1;
}

int main(void) {

    scanf("%d", &N);

    for (int i = 0; i < N; i++)
    {
        scanf("%s", str);

        int c = 0;

        for (int j = 0; j < 32; j++)
        {
            if(!str[j]) break;
            else c++;
        }

        int key = getHashKey(str, c);
        int cnt = checking(str, c, key);

        if(cnt != -1) {
            printf("%s%d\n", str, cnt);
        }
        else {
            printf("OK\n");
        }

    }

    return 0;
}


#include <iostream>
using namespace std;

int main()
{
	int n, m;
	cin >> n >> m;
	char** arr;
	arr = new char*[n];
	for (int i = 0; i < m; i++)
		arr[i] = new char[m];
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++)
		{
			cin >> arr[i][j];
			if (arr[i][j] == '.')
				if ((i + j) % 2 == 1)
					arr[i][j] = 'B';
				else
					arr[i][j] = 'W';
		}
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
			cout << arr[i][j] << " ";
		cout << endl;
	}
}


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

void main()
{
	int n, m;
	char array1[100][100];
	cin>>n;
	cin>>m;
	for(int i = 0; i<n; i++)
		for(int j=0; j<m; j++)
			cin>>array1[i][j];

	for(int i = 0; i<n; i++)
		for(int j=0; j<m; j++)
			if(array1[i][j]=='.')
			{
				if(i==0 && j==0)
					array1[0][0] = 'B';
				else
					if(i==0)
						if(array1[i][j-1]=='B')
							array1[i][j] = 'W';
						else
							array1[i][j] = 'B';
					if(j==0)
						if(array1[i-1][j]=='B')
							array1[i][j] = 'W';
						else
							array1[i][j] = 'B';
					if(array1[i-1][j]==array1[i][j-1])
						if(array1[i-1][j]=='B')
							array1[i][j] = 'W';
						else
							array1[i][j] = 'B';
			}
	for(int i = 0; i<n; i++)
	{	for(int j=0; j<m; j++)
			cout<<array1[i][j]<<' ';
		cout << endl;
	}
}


int main()
{
    int n, m;
    cin >> n >> m;
    char* arr;
    arr = new char[n][m];
    for (int i = 0; i < n; i++)
        for (int j = 0; j < 0; j++)
        {
            cin >> arr[i][j];
            if (arr[i][j] == '.')
                if ((i + j)%2 == 1)
                    arr[i][j] = 'B';
                else
                    arr[i][j] = 'W';
        }
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < 0; j++)
            cout << arr[i][j] << " ";
        cout << endl;
    }
}


#include <iostream>
using namespace std;

int main()
{
	int n, m;
	cin >> n >> m;
	char** arr;
	arr = new char*[n];
	for (int i = 0; i < n; i++)
		arr[i] = new char[m];
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++)
		{
			cin >> arr[i][j];
			if (arr[i][j] == '.')
				if ((i + j) % 2 == 1)
					arr[i][j] = 'B';
				else
					arr[i][j] = 'W';
		}
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
			cout << arr[i][j];
		cout << endl;
	}
}


#include <iostream>
using namespace std;

int main()
{
	int n, m;
	cin >> n >> m;
	char** arr;
	arr = new char*[n];
	for (int i = 0; i < m; i++)
		arr[i] = new char[m];
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++)
		{
			cin >> arr[i][j];
			if (arr[i][j] == '.')
				if ((i + j) % 2 == 1)
					arr[i][j] = 'B';
				else
					arr[i][j] = 'W';
		}
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
			cout << arr[i][j];
		cout << endl;
	}
}


#include <iostream>
using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    char* arr;
    arr = new char[n][m];
    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++)
        {
            cin >> arr[i][j];
            if (arr[i][j] == '.')
                if ((i + j)%2 == 1)
                    arr[i][j] = 'B';
                else
                    arr[i][j] = 'W';
        }
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
            cout << arr[i][j] << " ";
        cout << endl;
    }
}


#include <iostream>
using namespace std;

int main()
{
	int n, m;
	cin >> n >> m;
	char** arr;
	arr = new char*[n];
	for (int i = 0; i < m; i++)
		arr[i] = new char[m];
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++)
		{
			cin >> arr[i][j];
			if (arr[i][j] == '.')
				if ((i + j) % 2 == 1)
					arr[i][j] = 'B';
				else
					arr[i][j] = 'W';
		}
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
			cout << arr[i][j];

		cout << endl;
	}
}


#include <iostream>
using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    char* arr;
    arr = new char[n][m];
    for (int i = 0; i < n; i++)
        for (int j = 0; j < 0; j++)
        {
            cin >> arr[i][j];
            if (arr[i][j] == '.')
                if ((i + j)%2 == 1)
                    arr[i][j] = 'B';
                else
                    arr[i][j] = 'W';
        }
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < 0; j++)
            cout << arr[i][j] << " ";
        cout << endl;
    }
}


#include<iostream>
#include<string>
#include<cstring>
#include<unordered_map>
#include<sstream>
#include<stack>
#include<queue>
#include<list>
#include<vector>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<iomanip>
#include<tuple>
#include<map>
#include <new>
using namespace std;

void main()
{
	int n, m,i,j;
	char arr[100][100],tmp1='B',tmp2='W';
	bool pass = true;
	cin >> n >> m;
	for (i = 0; i < n; i++)
		for (j = 0; j < m; j++)
			cin >> arr[i][j];
	for (i = 0; i < n; i++)
	{
		for (j = 0; j < m; j++)
		{
			if (arr[i][j] == '.')
			{
				if (j > 0&&arr[i][j-1]!='-')
				{
					if (arr[i][j - 1] == tmp1)
						arr[i][j] = tmp2;
					else
						arr[i][j] = tmp1;
				}
				else if (i > 0 && arr[i-1][j] != '-')
				{
					if (arr[i - 1][j] == tmp1)
						arr[i][j] = tmp2;
					else
						arr[i][j] = tmp1;
				}
				else if (i < n - 1 && arr[i + 1][j] != '-')
				{
					if (arr[i + 1][j] == tmp1)
						arr[i][j] = tmp2;
					else
						arr[i][j] = tmp1;
				}
				else if (j < m - 1 && arr[i][j + 1] != '-')
				{
					if (arr[i][j + 1] == tmp1)
						arr[i][j] = tmp2;
					else
						arr[i][j] = tmp1;
				}
				else
					arr[i][j] == tmp1;
			}
		}
	}
	for (i = 0; i < n; i++)
	{
		for (j = 0; j < m; j++)
			cout << arr[i][j];
		cout << endl;
	}

}


#include<iostream>
#include<string>
#include<cstring>
#include<unordered_map>
#include<sstream>
#include<stack>
#include<queue>
#include<list>
#include<vector>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<iomanip>
#include<tuple>
#include<map>
#include <new>
using namespace std;

void main()
{
	int n, m,i,j;
	char arr[100][100], ar[100][100] = {'a'};
	bool pass = true;
	cin >> n >> m;
	for (i = 0; i < n; i++)
		for (j = 0; j < m; j++)
			cin >> arr[i][j];
	for (i = 0; i < n; i++)
	{
		for (j = 0; j < m; j++)
		{
			if (i == 0 && j == 0)
			{
				ar[i][j] = 'B';
			}
			else
			{
				if (j > 0)
				{
					if (ar[i][j - 1] == 'B')
						ar[i][j] = 'W';
					else
						ar[i][j] = 'B';
				}
				else if (i > 0)
				{
					if (ar[i-1][j] == 'B')
						ar[i][j] = 'W';
					else
						ar[i][j] = 'B';
				}
			}
		}
	}

	for (i = 0; i < n; i++)
	{
		for (j = 0; j < m; j++)
		{
			if (arr[i][j] == '.')
			{
				arr[i][j] = ar[i][j];
			}
		}
	}
	for (i = 0; i < n; i++)
	{
		for (j = 0; j < m; j++)
			cout << arr[i][j];
		cout << endl;
	}
}


#include<iostream>
#include<string>
#include<cstring>
#include<unordered_map>
#include<sstream>
#include<stack>
#include<queue>
#include<list>
#include<vector>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<iomanip>
#include<tuple>
#include<map>
#include <new>
using namespace std;

void main()
{
	int n, m,i,j;
	char arr[100][100],tmp1='B',tmp2='W';
	bool pass = true;
	cin >> n >> m;
	for (i = 0; i < n; i++)
		for (j = 0; j < m; j++)
			cin >> arr[i][j];
	for (i = 0; i < n; i++)
	{
		for (j = 0; j < m; j++)
		{
			if (arr[i][j] == '.')
			{
				if (j > 0&&arr[i][j-1]!='-')
				{
					if (arr[i][j - 1] == tmp1)
						arr[i][j] = tmp2;
					else
						arr[i][j] = tmp1;
				}
				else if (i > 0 && arr[i-1][j] != '-')
				{
					if (arr[i - 1][j] == tmp1)
						arr[i][j] = tmp2;
					else
						arr[i][j] = tmp1;
				}
				else if (i < n - 1 && arr[i + 1][j] != '-')
				{
					if (arr[i + 1][j] == tmp1)
						arr[i][j] = tmp2;
					else
						arr[i][j] = tmp1;
				}
				else if (j < m - 1 && arr[i][j + 1] != '-')
				{
					if (arr[i][j + 1] == tmp1)
						arr[i][j] = tmp2;
					else
						arr[i][j] = tmp1;
				}
				else{
					arr[i][j] = tmp1;
				}
			}
		}
	}
	for (i = 0; i < n; i++)
	{
		for (j = 0; j < m; j++)
			cout << arr[i][j];
		cout << endl;
	}

}


#include<iostream>
using namespace std;
char c[100][100];
int main(){
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++){
            cin >> c[i][j];
            if (c[i][j] == '-'){
                if ((i + j) % 2)
                    c[i][j] = 'W';
                else
                    c[i][j] = 'B';

            }

    }
    for (int i = 0; i < n; i++){
        for (int j = 0; j < m; j++){
            cout << c[i][j];
        }
    cout << endl;
    }

}


#include<iostream>
using namespace std;
char c[100][100];
int main(){
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++){
            cin >> c[i][j];
            if (c[i][j]!= '-'){
                if ((i + j) % 2)
                    c[i][j] = 'W';
                else
                    c[i][j] = 'B';

            }

    }
    for (int i = 0; i < n; i++){
        for (int j = 0; j < m; j++){
            cout << c[i][j];
        }
    cout << endl;
    }

}


#include<iostream>
using namespace std;
char c[100][100];
int main(){
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < n; i++){
        for (int j = 0; j < m; j++){
            cin >> c[i][j];
            if (c[i][j] == '-'){
                if ((i + j) % 2)
                    c[i][j] = 'W';
                else
                    c[i][j] = 'B';

            }
            cout << c[i][j];
        }
        cout << endl;
    }
    cin >> n;

}


#include<iostream>
#include<vector>
#include<utility>
#include<utility>
#include<set>
#include<algorithm>

using namespace std;
int  main()
{
    char a[100][100];
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < n;i++)
        for (int j = 0; j < m; j++)
            cin >> a[i][j];
        for (int i = 0; i < n; i++)
        {
            for (int j = 0; j < m; j++)
            {
                if (a[i][j] == '.')
                if (a[i - 1][j] != 'w'&&a[i + 1][j] != 'w'&&a[i][j + 1] != 'w'&&a[i][j - 1] != 'w')
                    cout << 'w', a[i][j] = 'w';
                else cout << 'b', a[i][j] = 'b';
                else
                    cout << a[i][j];
            }
            cout << endl;
        }

}


#include<iostream>
#include<vector>
#include<utility>
#include<utility>
#include<set>
#include<algorithm>

using namespace std;
int  main()
{
    char a[100][100];
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < n;i++)
        for (int j = 0; j < m; j++)
            cin >> a[i][j];
        for (int i = 0; i < n; i++)
        {
            for (int j = 0; j < m; j++)
            {
                if (a[i][j] == '.')
                    i % 2 == j % 2 ? cout << "B" : cout << "W";
                else
                    cout << a[i][j];
            }
            cout << endl;
        }

}


#include<iostream>
#include<vector>
#include<utility>
#include<utility>
#include<set>
#include<algorithm>

using namespace std;
int  main()
{
    char a[100][100];
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < n;i++)
        for (int j = 0; j < m; j++)
            cin >> a[i][j];
        for (int i = 0; i < n; i++)
        {
            for (int j = 0; j < m; j++)
            {
                if (a[i][j] == '.')
                if (a[i - 1][j] != 'b'&&a[i + 1][j] != 'b'&&a[i][j + 1] != 'b'&&a[i][j - 1] != 'b')
                    cout << 'b', a[i][j] = 'b';
                else cout << 'w', a[i][j] = 'w';
                else
                    cout << a[i][j];
            }
            cout << endl;
        }

}


#include<iostream>
#include<vector>
#include<utility>
#include<utility>
#include<set>
#include<algorithm>

using namespace std;
int  main()
{
    char a[100][100];
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < n;i++)
        for (int j = 0; j < m; j++)
            cin >> a[i][j];
        for (int i = 0; i < n; i++)
        {
            for (int j = 0; j < m; j++)
            {
                if (a[i][j] == '.')
                if (a[i - 1][j] != 'B'&&a[i + 1][j] != 'B'&&a[i][j + 1] != 'B'&&a[i][j - 1] != 'B')
                    cout << 'B', a[i][j] = 'B';
                else cout << 'W', a[i][j] = 'W';
                else
                    cout << a[i][j];
            }
            cout << endl;
        }

}


#include <cstdlib>

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

#include <vector>

#define endl '\n'

int n, m;
bool arr[110][110];
int ans[110][110];

void solve(){
    cin >> n >> m;
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < m; ++j){
            char c;
            cin >> c;
            arr[i][j] = c == '.';
        }
    for (int i = 0 ; i < n; ++i)
        for (int j = 0; j < m; ++j)
            if (arr[i][j]){
                if (i > 0 && ans[i - 1][j] != 0) ans[i][j] = -1 * ans[i - 1][j];
                else if (j > 0 && ans[i][j - 1] != 0) ans[i][j] = -1 * ans[i][j - 1];
                else ans[i][j] = 1;
            }
    for (int i = 0; i < n; ++i){
        for (int j = 0; j < m; ++j)
                //cout << ans[i][j];
            if (ans[i][j] == 0) cout << '-';
            else (ans[i][j] > 0) ? (cout << 'B') : (cout << 'W');//*/
        cout << endl;
    }
}

int main(void){
    #ifdef  TORTE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    solve();

    return 0;
}


#include <cstdlib>

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

#include <vector>

#define endl '\n'

int n, m;
bool arr[110][110];
int ans[110][110];

void solve(){
    cin >> n >> m;
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < m; ++j){
            char c;
            cin >> c;
            arr[i][j] = c == '.';
        }
    for (int i = 0 ; i < n; ++i)
        for (int j = 0; j < m; ++j)
            if (arr[i][j]){
                if (i >= 0 && ans[i - 1][j] != 0) ans[i][j] = -1 * ans[i - 1][j];
                else if (j >= 0 && ans[i][j - 1] != 0) ans[i][j] = -1 * ans[i][j - 1];
                else ans[i][j] = 1;
            }
    for (int i = 0; i < n; ++i){
        for (int j = 0; j < m; ++j)
                //cout << ans[i][j];
            if (ans[i][j] == 0) cout << '-';
            else (ans[i][j] == 2) ? (cout << 'B') : (cout << 'W');//*/
        cout << endl;
    }
}

int main(void){
    #ifdef  TORTE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    solve();

    return 0;
}


#include <cstdlib>

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

#include <vector>

#define endl '\n'

int n, m;

void solve(){
    cin >> n >> m;
    bool color = false;
    for (int i = 0; i < n; ++i){
        for (int j = 0, color = i % 2; j < m; ++j, color = !color){
            char c;
            cin >> c;
            if (c == '-') cout << '-';
            else (color) ? (cout << 'W') : (cout << 'B');
        }
        cout << endl;
    }
}

int main(void){
    #ifdef  TORTE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    solve();

    return 0;
}


#include <cstdlib>

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

#include <vector>

#define endl '\n'

int n, m;
bool arr[110][110];
int ans[110][110];

void solve(){
    cin >> n >> m;
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < m; ++j){
            char c;
            cin >> c;
            arr[i][j] = c == '.';
        }

    for (int i = 0; i < n; ++i){
        for (int j = 0; j < m; ++j)
            if (!arr[i][j]) cout << '-';
            else ((i % 2 + j % 2) % 2) ? (cout << 'B') : (cout << 'W');//*/
        cout << endl;
    }
}

int main(void){
    #ifdef  TORTE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    solve();

    return 0;
}


#include <cstdlib>

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

#include <vector>

#define endl '\n'

int n, m;

void solve(){
    cin >> n >> m;
    bool color = false;
    for (int i = 0; i < n; i++, cout << endl)
        for (int j = 0; j < m; ++j, color = !color){
            char c;
            cin >> c;
            if (c == '-') cout << '-';
            else (color) ? (cout << 'B') : (cout << 'W');
        }
}

int main(void){
    #ifdef  TORTE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    solve();

    return 0;
}


	//A. DZY Loves Chessboard
	//�ڷ����̣��ڰ���䣬ֻ�������Ǻõĸ����аڷ�
	#include<stdio.h>
	#include<windows.h>

	#define MAXROWS 50
	#define MAXCOLS 100
	void  setCharByAdjacent(char chessBoard[MAXROWS][MAXCOLS],int &row,int &col,int &m){
	if(row==0)
	{  //����߽��������һ��
		if(col==0)
			chessBoard[row][col]='B';
		else
			{if(chessBoard[row][col-1] !='-' )
			{
				if(chessBoard[row][col-1]=='B')
					chessBoard[row][col] = 'W';
				else
					chessBoard[row][col]='B';
		}
		chessBoard[row][col]='B';
		}
	}
	else if(col==0){//����߽��������һ��
		if(chessBoard[row-1][col] !='-')
		{
			if(chessBoard[row-1][col]=='B')
				chessBoard[row][col] = 'W';
			else
				chessBoard[row][col]='B';
		}
		else
		{
			if(chessBoard[row-1][col+1] !='-')
				chessBoard[row][col] = chessBoard[row-1][col+1];
			else
				chessBoard[row][col] = 'B';
		}
	}
	else if(col==m-1){ //�ұ߽磬ֻ�迼�Ǻ�����Լ��Ϸ�Ԫ�ز�ͬ
		if(chessBoard[row-1][col] !='-'){//���Ⱥ��Ϸ�Ԫ�ز�ͬ��
			if(chessBoard[row-1][col]=='B')
				chessBoard[row][col] = 'W';
			else
				chessBoard[row][col]='B';
		}
		else if(chessBoard[row][col-1] !='-')//����Ϸ�Ϊ��,������ߵ�Ԫ��
		{
			if(chessBoard[row][col-1]=='B')
				chessBoard[row][col] = 'W';
			else
				chessBoard[row][col]='B';
		}
		else{  //������ϼ�����λ��Ϊ�գ�������ֵ
			chessBoard[row][col] = 'B';
		}
	}
	else{
		if(chessBoard[row-1][col] !='-'){//���Ⱥ��Ϸ�Ԫ�ز�ͬ��
			if(chessBoard[row-1][col]=='B')
				chessBoard[row][col] = 'W';
			else
				chessBoard[row][col]='B';
		}
		else if(chessBoard[row][col-1] !='-')//����Ϸ�Ϊ��,������ߵ�Ԫ��
		{
			if(chessBoard[row][col-1]=='B')
				chessBoard[row][col] = 'W';
			else
				chessBoard[row][col]='B';
		}
		else if(chessBoard[row-1][col+1] !='-'){   //���ǰ���߶�Ϊ�գ��������Ϸ�
			if(chessBoard[row-1][col+1] !='-')
				chessBoard[row][col] = chessBoard[row-1][col+1];
		}
		else{  //������ϼ�����λ��Ϊ�գ�������ֵ
			chessBoard[row][col] = 'B';
		}
	}
	}

	void main(){
	printf("����������n������m:\n");
	int n=0,m=0; //���������
	char chessBoard[MAXROWS][MAXCOLS];
	int row,col;
	scanf("%d%d",&n,&m);
	printf("���������̸���״��:\n");
	for( row=0;row<n;row++)
	{
		getchar();
		for(col=0;col<m;col++)
		{
			scanf("%c",&chessBoard[row][col]);
		}
	}
	printf("���Ӱڷ����:\n");
	for( row=0;row<n;row++)
		{for(col=0;col<m;col++)
		{
			if(chessBoard[row][col]=='.')
				setCharByAdjacent(chessBoard,row,col,m);
			printf("%c",chessBoard[row][col]);
	}
	printf("\n");
	}
	system("pause");
	}


	//A. DZY Loves Chessboard
	//�ڷ����̣��ڰ���䣬ֻ�������Ǻõĸ����аڷ�
	#include<stdio.h>

	#define MAXROWS 50
	#define MAXCOLS 100
	void  setCharByAdjacent(char chessBoard[MAXROWS][MAXCOLS],int &row,int &col,int &m){
	if(row==0)
	{  //����߽��������һ��
		if(col==0)
			chessBoard[row][col]='B';
		else
			{if(chessBoard[row][col-1] !='-' )
			{
				if(chessBoard[row][col-1]=='B')
					chessBoard[row][col] = 'W';
				else
					chessBoard[row][col]='B';
		}
		chessBoard[row][col]='B';
		}
	}
	else if(col==0){//����߽��������һ��
		if(chessBoard[row-1][col] !='-')
		{
			if(chessBoard[row-1][col]=='B')
				chessBoard[row][col] = 'W';
			else
				chessBoard[row][col]='B';
		}
		else
		{
			if(chessBoard[row-1][col+1] !='-')
				chessBoard[row][col] = chessBoard[row-1][col+1];
			else
				chessBoard[row][col] = 'B';
		}
	}
	else if(col==m-1){ //�ұ߽磬ֻ�迼�Ǻ�����Լ��Ϸ�Ԫ�ز�ͬ
		if(chessBoard[row-1][col] !='-'){//���Ⱥ��Ϸ�Ԫ�ز�ͬ��
			if(chessBoard[row-1][col]=='B')
				chessBoard[row][col] = 'W';
			else
				chessBoard[row][col]='B';
		}
		else if(chessBoard[row][col-1] !='-')//����Ϸ�Ϊ��,������ߵ�Ԫ��
		{
			if(chessBoard[row][col-1]=='B')
				chessBoard[row][col] = 'W';
			else
				chessBoard[row][col]='B';
		}
		else{  //������ϼ�����λ��Ϊ�գ�������ֵ
			chessBoard[row][col] = 'B';
		}
	}
	else{
		if(chessBoard[row-1][col] !='-'){//���Ⱥ��Ϸ�Ԫ�ز�ͬ��
			if(chessBoard[row-1][col]=='B')
				chessBoard[row][col] = 'W';
			else
				chessBoard[row][col]='B';
		}
		else if(chessBoard[row][col-1] !='-')//����Ϸ�Ϊ��,������ߵ�Ԫ��
		{
			if(chessBoard[row][col-1]=='B')
				chessBoard[row][col] = 'W';
			else
				chessBoard[row][col]='B';
		}
		else if(chessBoard[row-1][col+1] !='-'){   //���ǰ���߶�Ϊ�գ��������Ϸ�
			if(chessBoard[row-1][col+1] !='-')
				chessBoard[row][col] = chessBoard[row-1][col+1];
		}
		else{  //������ϼ�����λ��Ϊ�գ�������ֵ
			chessBoard[row][col] = 'B';
		}
	}
	}

	void main(){
	printf("����������n������m:\n");
	int n=0,m=0; //���������
	char chessBoard[MAXROWS][MAXCOLS];
	int row,col;
	scanf("%d%d",&n,&m);
	printf("���������̸���״��:\n");
	for( row=0;row<n;row++)
	{
		getchar();
		for(col=0;col<m;col++)
		{
			scanf("%c",&chessBoard[row][col]);
		}
	}
	printf("���Ӱڷ����:\n");
	for( row=0;row<n;row++)
		{for(col=0;col<m;col++)
		{
			if(chessBoard[row][col]=='.')
				setCharByAdjacent(chessBoard,row,col,m);
			printf("%c",chessBoard[row][col]);
	}
	printf("\n");
	}
	}


	//A. DZY Loves Chessboard
	//�ڷ����̣��ڰ���䣬ֻ�������Ǻõĸ����аڷ�
	#include<stdio.h>

	#define MAXROWS 50
	#define MAXCOLS 100

	void setCharByIJ(char chessBoard[MAXROWS][MAXCOLS],int &row,int &col){
	if((row+col)%2==0)
		chessBoard[row][col]='B';
	else
		chessBoard[row][col]='W';
	}
	void main(){
	int n=0,m=0; //���������
	char chessBoard[MAXROWS][MAXCOLS];
	int row,col;
	scanf("%d%d",&n,&m);
	for( row=0;row<n;row++)
	{
		getchar();
		for(col=0;col<m;col++)
		{
			scanf("%c",&chessBoard[row][col]);
		}
	}
	for( row=0;row<n;row++)
		{for(col=0;col<m;col++)
		{
			if(chessBoard[row][col]=='.')
				setCharByIJ(chessBoard,row,col);
			printf("%c",chessBoard[row][col]);
	}
	printf("\n");
	}
	}


	//A. DZY Loves Chessboard
	//�ڷ����̣��ڰ���䣬ֻ�������Ǻõĸ����аڷ�
	#include<stdio.h>

	#define MAXROWS 50
	#define MAXCOLS 100
	void  setCharByAdjacent(char chessBoard[MAXROWS][MAXCOLS],int &row,int &col,int &m){
	if(row==0)
	{  //����߽��������һ��
		if(col==0)
			chessBoard[row][col]='B';
		else
			{if(chessBoard[row][col-1] !='-' )
			{
				if(chessBoard[row][col-1]=='B')
					chessBoard[row][col] = 'W';
				else
					chessBoard[row][col]='B';
		}
		chessBoard[row][col]='B';
		}
	}
	else if(col==0){//����߽��������һ��
		if(chessBoard[row-1][col] !='-')
		{
			if(chessBoard[row-1][col]=='B')
				chessBoard[row][col] = 'W';
			else
				chessBoard[row][col]='B';
		}
		else
		{
			if(chessBoard[row-1][col+1] !='-')
				chessBoard[row][col] = chessBoard[row-1][col+1];
			else
				chessBoard[row][col] = 'B';
		}
	}
	else if(col==m-1){ //�ұ߽磬ֻ�迼�Ǻ�����Լ��Ϸ�Ԫ�ز�ͬ
		if(chessBoard[row-1][col] !='-'){//���Ⱥ��Ϸ�Ԫ�ز�ͬ��
			if(chessBoard[row-1][col]=='B')
				chessBoard[row][col] = 'W';
			else
				chessBoard[row][col]='B';
		}
		else if(chessBoard[row][col-1] !='-')//����Ϸ�Ϊ��,������ߵ�Ԫ��
		{
			if(chessBoard[row][col-1]=='B')
				chessBoard[row][col] = 'W';
			else
				chessBoard[row][col]='B';
		}
		else{  //������ϼ�����λ��Ϊ�գ�������ֵ
			chessBoard[row][col] = 'B';
		}
	}
	else{
		if(chessBoard[row-1][col] !='-'){//���Ⱥ��Ϸ�Ԫ�ز�ͬ��
			if(chessBoard[row-1][col]=='B')
				chessBoard[row][col] = 'W';
			else
				chessBoard[row][col]='B';
		}
		else if(chessBoard[row][col-1] !='-')//����Ϸ�Ϊ��,������ߵ�Ԫ��
		{
			if(chessBoard[row][col-1]=='B')
				chessBoard[row][col] = 'W';
			else
				chessBoard[row][col]='B';
		}
		else if(chessBoard[row-1][col+1] !='-'){   //���ǰ���߶�Ϊ�գ��������Ϸ�
			if(chessBoard[row-1][col+1] !='-')
				chessBoard[row][col] = chessBoard[row-1][col+1];
		}
		else{  //������ϼ�����λ��Ϊ�գ�������ֵ
			chessBoard[row][col] = 'B';
		}
	}
	}

	void main(){
	int n=0,m=0; //���������
	char chessBoard[MAXROWS][MAXCOLS];
	int row,col;
	scanf("%d%d",&n,&m);
	for( row=0;row<n;row++)
	{
		getchar();
		for(col=0;col<m;col++)
		{
			scanf("%c",&chessBoard[row][col]);
		}
	}
	for( row=0;row<n;row++)
		{for(col=0;col<m;col++)
		{
			if(chessBoard[row][col]=='.')
				setCharByAdjacent(chessBoard,row,col,m);
			printf("%c",chessBoard[row][col]);
	}
	printf("\n");
	}
	}


	//A. DZY Loves Chessboard
	//�ڷ����̣��ڰ���䣬ֻ�������Ǻõĸ����аڷ�
	#include<stdio.h>

	#define MAXROWS 1000
	#define MAXCOLS 100

	void setCharByIJ(char chessBoard[MAXROWS][MAXCOLS],int &row,int &col){
	if((row+col)%2==0)
		chessBoard[row][col]='B';
	else
		chessBoard[row][col]='W';
	}
	void main(){
	int n=0,m=0; //���������
	char chessBoard[MAXROWS][MAXCOLS];
	int row,col;
	scanf("%d%d",&n,&m);
	for( row=0;row<n;row++)
	{
		getchar();
		for(col=0;col<m;col++)
		{
			scanf("%c",&chessBoard[row][col]);
		}
	}
	for( row=0;row<n;row++)
		{for(col=0;col<m;col++)
		{
			if(chessBoard[row][col]=='.')
				setCharByIJ(chessBoard,row,col);
			printf("%c",chessBoard[row][col]);
	}
	printf("\n");
	}
	}


	//A. DZY Loves Chessboard
	//�ڷ����̣��ڰ���䣬ֻ�������Ǻõĸ����аڷ�
	#include<stdio.h>
	#include<windows.h>

	#define MAXROWS 50
	#define MAXCOLS 100
	void  setCharByAdjacent(char chessBoard[MAXROWS][MAXCOLS],int &row,int &col,int &m){
	if(row==0)
	{  //����߽��������һ��
		if(col==0)
			chessBoard[row][col]='B';
		else
			{if(chessBoard[row][col-1] !='-' )
			{
				if(chessBoard[row][col-1]=='B')
					chessBoard[row][col] = 'W';
				else
					chessBoard[row][col]='B';
		}
		chessBoard[row][col]='B';
		}
	}
	else if(col==0){//����߽��������һ��
		if(chessBoard[row-1][col] !='-')
		{
			if(chessBoard[row-1][col]=='B')
				chessBoard[row][col] = 'W';
			else
				chessBoard[row][col]='B';
		}
		else
		{
			if(chessBoard[row-1][col+1] !='-')
				chessBoard[row][col] = chessBoard[row-1][col+1];
			else
				chessBoard[row][col] = 'B';
		}
	}
	else if(col==m-1){ //�ұ߽磬ֻ�迼�Ǻ�����Լ��Ϸ�Ԫ�ز�ͬ
		if(chessBoard[row-1][col] !='-'){//���Ⱥ��Ϸ�Ԫ�ز�ͬ��
			if(chessBoard[row-1][col]=='B')
				chessBoard[row][col] = 'W';
			else
				chessBoard[row][col]='B';
		}
		else if(chessBoard[row][col-1] !='-')//����Ϸ�Ϊ��,������ߵ�Ԫ��
		{
			if(chessBoard[row][col-1]=='B')
				chessBoard[row][col] = 'W';
			else
				chessBoard[row][col]='B';
		}
		else{  //������ϼ�����λ��Ϊ�գ�������ֵ
			chessBoard[row][col] = 'B';
		}
	}
	else{
		if(chessBoard[row-1][col] !='-'){//���Ⱥ��Ϸ�Ԫ�ز�ͬ��
			if(chessBoard[row-1][col]=='B')
				chessBoard[row][col] = 'W';
			else
				chessBoard[row][col]='B';
		}
		else if(chessBoard[row][col-1] !='-')//����Ϸ�Ϊ��,������ߵ�Ԫ��
		{
			if(chessBoard[row][col-1]=='B')
				chessBoard[row][col] = 'W';
			else
				chessBoard[row][col]='B';
		}
		else if(chessBoard[row-1][col+1] !='-'){   //���ǰ���߶�Ϊ�գ��������Ϸ�
			if(chessBoard[row-1][col+1] !='-')
				chessBoard[row][col] = chessBoard[row-1][col+1];
			//else
			//	chessBoard[row][col] = 'B';
		}
		else{  //������ϼ�����λ��Ϊ�գ�������ֵ
			chessBoard[row][col] = 'B';
		}
	}
	}

	void main(){
	printf("����������n������m:\n");
	int n=0,m=0; //���������
	char chessBoard[MAXROWS][MAXCOLS];
	int row,col;
	//	getchar();
	scanf("%d%d",&n,&m);
	//	scanf("%d",&m);
	printf("���������̸���״��:\n");
//	getchar();
	for( row=0;row<n;row++)
	{
		getchar();
		for(col=0;col<m;col++)
		{
	//			getchar();
			scanf("%c",&chessBoard[row][col]);
		}
	}
	printf("���Ӱڷ����:\n");
	for( row=0;row<n;row++)
		{for(col=0;col<m;col++)
		{
			if(chessBoard[row][col]=='.')
				setCharByAdjacent(chessBoard,row,col,m);
			printf("%c",chessBoard[row][col]);
	}
	printf("\n");
	}
	system("pause");
	}


	//A. DZY Loves Chessboard
	//�ڷ����̣��ڰ���䣬ֻ�������Ǻõĸ����аڷ�
	#include<stdio.h>

	#define MAXROWS 50
	#define MAXCOLS 100
	void  setCharByAdjacent(char chessBoard[MAXROWS][MAXCOLS],int &row,int &col,int &m){
	if(row==0)
	{  //����߽��������һ��
		if(col==0)
			chessBoard[row][col]='B';
		else
			{if(chessBoard[row][col-1] !='-' )
			{
				if(chessBoard[row][col-1]=='B')
					chessBoard[row][col] = 'W';
				else
					chessBoard[row][col]='B';
		}
		else
			chessBoard[row][col]='B';
		}
	}
	else if(col==0){//����߽��������һ��
		if(chessBoard[row-1][col] !='-')
		{
			if(chessBoard[row-1][col]=='B')
				chessBoard[row][col] = 'W';
			else
				chessBoard[row][col]='B';
		}
		else
		{
			if(chessBoard[row-1][col+1] !='-')
				chessBoard[row][col] = chessBoard[row-1][col+1];
			else
				chessBoard[row][col] = 'B';
		}
	}
	else if(col==m-1){ //�ұ߽磬ֻ�迼�Ǻ�����Լ��Ϸ�Ԫ�ز�ͬ
		if(chessBoard[row-1][col] !='-'){//���Ⱥ��Ϸ�Ԫ�ز�ͬ��
			if(chessBoard[row-1][col]=='B')
				chessBoard[row][col] = 'W';
			else
				chessBoard[row][col]='B';
		}
		else if(chessBoard[row][col-1] !='-')//����Ϸ�Ϊ��,������ߵ�Ԫ��
		{
			if(chessBoard[row][col-1]=='B')
				chessBoard[row][col] = 'W';
			else
				chessBoard[row][col]='B';
		}
		else{  //������ϼ�����λ��Ϊ�գ�������ֵ
			chessBoard[row][col] = 'B';
		}
	}
	else{
		if(chessBoard[row-1][col] !='-'){//���Ⱥ��Ϸ�Ԫ�ز�ͬ��
			if(chessBoard[row-1][col]=='B')
				chessBoard[row][col] = 'W';
			else
				chessBoard[row][col]='B';
		}
		else if(chessBoard[row][col-1] !='-')//����Ϸ�Ϊ��,������ߵ�Ԫ��
		{
			if(chessBoard[row][col-1]=='B')
				chessBoard[row][col] = 'W';
			else
				chessBoard[row][col]='B';
		}
		else if(chessBoard[row-1][col+1] !='-'){   //���ǰ���߶�Ϊ�գ��������Ϸ�
			if(chessBoard[row-1][col+1] !='-')
				chessBoard[row][col] = chessBoard[row-1][col+1];
		}
		else{  //������ϼ�����λ��Ϊ�գ�������ֵ
			chessBoard[row][col] = 'B';
		}
	}
	}

	void main(){
	int n=0,m=0; //���������
	char chessBoard[MAXROWS][MAXCOLS];
	int row,col;
	scanf("%d%d",&n,&m);
	for( row=0;row<n;row++)
	{
		getchar();
		for(col=0;col<m;col++)
		{
			scanf("%c",&chessBoard[row][col]);
		}
	}
	for( row=0;row<n;row++)
		{for(col=0;col<m;col++)
		{
			if(chessBoard[row][col]=='.')
				setCharByAdjacent(chessBoard,row,col,m);
			printf("%c",chessBoard[row][col]);
	}
	printf("\n");
	}
	}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <iomanip>
#include <queue>
#define ll long long
using namespace std;
char matrix[202][202];
char ans[201][201];

int main(){
	//freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);

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

	for (int i = 1; i <= n; i++){
		for (int j = 1; j <= m; j++){
			cin >> matrix[i][j];
		}
	}

	char ch[2] = { 'B', 'W' };
	bool flag = true;
	for (int i = 1; i <= n; i++){
		if ((m % 2 == 0)) flag = !flag;
		for (int j = 1; j <= m; j++){

			if (matrix[i][j] == '.') {
				matrix[i][j] = ch[flag];
			}
			flag = !flag;

		}
	}
	// B w B w
	for (int i = 1; i <= n; i++){
		for (int j = 1; j <= m; j++){
			cout << matrix[i][j];
		}
		cout << endl;
	}
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <iomanip>
#define ll long long
using namespace std;

int main(){
	//freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);

	int n, m;
	cin >> n >> m;
	char matrix[202][202];
	char ans[201][201];
	for (int i = 1; i <= n; i++){
		for (int j = 1; j <= m; j++){
			cin >> matrix[i][j];
		}
	}

	for (int i = 1; i <= n; i++){
		for (int j = 1; j <= m; j++){
			if (matrix[i][j] == '.'){
				if (ans[i - 1][j] != 'B' && ans[i + 1][j] != 'B' && ans[i][j - 1] != 'B' && ans[i][j + 1] != 'B')
					ans[i][j] = 'B';
				else ans[i][j] = 'W';
			}
			else {
				ans[i][j] = '-';
			}
		}
	}
	for (int i = 1; i <= n; i++){
		for (int j = 1; j <= m; j++){
			cout << ans[i][j];
		}
		cout << endl;
	}
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <iomanip>
#include <queue>
#define ll long long
using namespace std;
char matrix[202][202];
char ans[201][201];

int main(){
	//freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);

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

	for (int i = 1; i <= n; i++){
		for (int j = 1; j <= m; j++){
			cin >> matrix[i][j];
		}
	}

	char ch[2] = { 'B', 'W' };
	bool flag = true;
	for (int i = 1; i <= n; i++){
		for (int j = 1; j <= m; j++){
			flag = !flag;
			if (matrix[i][j] == '-') {
				continue;
			}
			matrix[i][j] = ch[flag];

		}
	}
	for (int i = 1; i <= n; i++){
		for (int j = 1; j <= m; j++){
			cout << matrix[i][j];
		}
		cout << endl;
	}
	return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int a,b,flag=0;
    cin>>a>>b;
    char **x=new char* [a];
    for(int i=0;i<a;i++){
       x[i]=new char [b];
    }
    for(int i=0;i<a;i++){
        if(i%2)
            flag=1;
        for(int j=0;j<b;j++)
        {
            cin>>x[i][j];
            if(x[i][j]=='.')
            {
                if(flag){
                    x[i][j]='W';
                    flag--;
                }
                else
                {
                    x[i][j]='B';
                    flag++;
                }
            }
        }
        cout<<"\n";
    }
    for(int i=0;i<a;i++){
        for(int j=0;j<b;j++)
        {
            cout<<x[i][j];
        }
        cout<<"\n";
    }
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int a,b,c,flag=0;
    cin>>a>>b;
    char **x=new char* [a];
    for(int i=0;i<a;i++){
       x[i]=new char [b];
    }
    for(int i=0;i<a;i++){
        if(i%2)
            flag=1;
        else flag=0;
        for(int j=0;j<b;j++)
        {
            cin>>x[i][j];
            c=x[i][j];
                if(flag){
                    x[i][j]='W';
                    flag--;
                }
                else
                {
                    x[i][j]='B';
                    flag++;
                }
                if(c=='-')
                    x[i][j]='-';
            }
        }
        cout<<"\n";
    for(int i=0;i<a;i++){
        for(int j=0;j<b;j++)
        {
            cout<<x[i][j];
        }
        cout<<"\n";
    }
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int a,b,flag=0;
    cin>>a>>b;
    char **x=new char* [a];
    for(int i=0;i<a;i++){
       x[i]=new char [b];
    }
    for(int i=0;i<a;i++){
        if(i%2)
            flag=1;
        for(int j=0;j<b;j++)
        {
            cin>>x[i][j];
            if(x[i][j]=='.')
            {
                if(flag){
                    x[i][j]='B';
                    flag--;
                }
                else
                {
                    x[i][j]='W';
                    flag++;
                }
            }
        }
        cout<<"\n";
    }
    for(int i=0;i<a;i++){
        for(int j=0;j<b;j++)
        {
            cout<<x[i][j]<<" ";
        }
        cout<<"\n";
    }
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int a,b,flag=0;
    cin>>a>>b;
    char **x=new char* [a];
    for(int i=0;i<a;i++){
       x[i]=new char [b];
    }
    for(int i=0;i<a;i++){
        for(int j=0;j<b;j++)
        {
            cin>>x[i][j];
            if(x[i][j]=='.')
            {
                if(flag){
                    x[i][j]='B';
                }
                else
                {
                    x[i][j]='W';
                }
                flag++;
            }
        }
        cout<<"\n";
    }
    for(int i=0;i<a;i++){
        for(int j=0;j<b;j++)
        {
            cout<<x[i][j]<<" ";
        }
        cout<<"\n";
    }
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int a,b,flag=0;
    cin>>a>>b;
    char **x=new char* [a];
    for(int i=0;i<a;i++){
       x[i]=new char [b];
    }
    for(int i=0;i<a;i++){
        if(i%2)
            flag=1;
        else flag=0;
        for(int j=0;j<b;j++)
        {
            cin>>x[i][j];
            if(x[i][j]=='.')
            {
                if(flag){
                    x[i][j]='W';
                    flag--;
                }
                else
                {
                    x[i][j]='B';
                    flag++;
                }
            }
        }
        cout<<"\n";
    }
    for(int i=0;i<a;i++){
        for(int j=0;j<b;j++)
        {
            cout<<x[i][j];
        }
        cout<<"\n";
    }
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int a,b,flag=0;
    cin>>a>>b;
    char **x=new char* [a];
    for(int i=0;i<a;i++){
       x[i]=new char [b];
    }
    for(int i=0;i<a;i++){
        for(int j=0;j<b;j++)
        {
            cin>>x[i][j];
            if(x[i][j]=='.')
            {
                if(flag){
                    x[i][j]='B';
                    flag++;
                }
                else
                {
                    x[i][j]='W';
                    flag++;
                }
            }
        }
        cout<<"\n";
    }
    for(int i=0;i<a;i++){
        for(int j=0;j<b;j++)
        {
            cout<<x[i][j]<<" ";
        }
        cout<<"\n";
    }
    return 0;
}


/*
@Author: Naseef
Chittagong University of Engineering & Technology
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <map>
#include <bitset>
#include <ctime>
#include <cmath>
#include <cassert>
#include <algorithm>
using namespace std;

#define pb(p) push_back(p)
#define fr(i,a,b) for(int i=a;i<b;i++)
#define frd(i,a,b) for(int i=a; i>=b i--)
#define PI 2*acos(0.0)
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()

int MIN (int a, int b) {
  int x= (b>a)?a:b;
  return x;
}

int MAX(int a, int b) {
  int x= (b<a)?a:b;
  return x;
}

#define maxn 10000000

/*vector<int>prime;
__int64 count[maxn+10];
bool visit[maxn+10];

void make_prime(){

		/*for( i=2;i*i<=MAX;i++ ){
        if( ntP[i] ) continue;
        for( j=i*i;j<=MAX;j+=i ) ntP[j] = true;
    int i,j;
    int pos1=sqrt((double)maxn)+1;
	visit[1]=true;
	visit[4]=true;
	visit[6]=true;
	visit[8]=true;
    for(i=3;i<=pos1;i++)
	{
		if(visit[i]==false)
		{
			for(j=i*i;j<=maxn;j=j+i+i)
			visit[j]=true;
		}
	}
    prime.push_back(2);
    for(j=3;j<=maxn;j+=2)
        if( visit[j]==false )prime.push_back(j);
}
*/
typedef long long ll;
const int size = 1000007;
const ll modulo = 1000000007;
const ll inf = 1e18;
const double eps = 1e-6;
ll n,m,a[4000],b[4000],k,n25,n50,n100;

/*
int gcd(int a,int b)
{
    while(b>0)
    {
        a%=b;
        a^=b;
        b^=a;
        a^=b;
    }
    return a;
}

ll lcm(ll a,ll b)
{
    return ((a*b)/gcd(a,b));
}*/

int main()
{
    #ifdef WRITE_IN_FILE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
	char ar[100][100];
	while(cin>>n>>m)
	{
		char ar1[2];
		ar1[0]='W';
		ar1[1]='B';

		for(int i=0;i<n;i++)
			for(int j=0;j<m;j++)
			{
				//char ch;
				cin>>ar[i][j];
			}

		for(int i=0;i<n;i++)
		{
			for(int j=0;j<m;j++)
			{
				if(ar[i][j]!='-')
					continue;
				if(i%2==0)
				{
					if(j%2==0)
						cout<<"W";
					else cout<<"B";
				}
				else
				{
					if(j%2==0)
						cout<<"B";
					else cout<<"W";
				}
			}

			cout<<endl;
		}
	}
	return 0;
}


/*
@Author: Naseef
Chittagong University of Engineering & Technology
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <map>
#include <bitset>
#include <ctime>
#include <cmath>
#include <cassert>
#include <algorithm>
using namespace std;

#define pb(p) push_back(p)
#define fr(i,a,b) for(int i=a;i<b;i++)
#define frd(i,a,b) for(int i=a; i>=b i--)
#define PI 2*acos(0.0)
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()

int MIN (int a, int b) {
  int x= (b>a)?a:b;
  return x;
}

int MAX(int a, int b) {
  int x= (b<a)?a:b;
  return x;
}

#define maxn 10000000

/*vector<int>prime;
__int64 count[maxn+10];
bool visit[maxn+10];

void make_prime(){

		/*for( i=2;i*i<=MAX;i++ ){
        if( ntP[i] ) continue;
        for( j=i*i;j<=MAX;j+=i ) ntP[j] = true;
    int i,j;
    int pos1=sqrt((double)maxn)+1;
	visit[1]=true;
	visit[4]=true;
	visit[6]=true;
	visit[8]=true;
    for(i=3;i<=pos1;i++)
	{
		if(visit[i]==false)
		{
			for(j=i*i;j<=maxn;j=j+i+i)
			visit[j]=true;
		}
	}
    prime.push_back(2);
    for(j=3;j<=maxn;j+=2)
        if( visit[j]==false )prime.push_back(j);
}
*/
typedef long long ll;
const int size = 1000007;
const ll modulo = 1000000007;
const ll inf = 1e18;
const double eps = 1e-6;
ll n,m,a[4000],b[4000],k,n25,n50,n100;

/*
int gcd(int a,int b)
{
    while(b>0)
    {
        a%=b;
        a^=b;
        b^=a;
        a^=b;
    }
    return a;
}

ll lcm(ll a,ll b)
{
    return ((a*b)/gcd(a,b));
}*/

int main()
{
    #ifdef WRITE_IN_FILE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
	char ar[100][100];
	while(cin>>n>>m)
	{
		char ar1[2];
		ar1[0]='W';
		ar1[1]='B';

		for(int i=0;i<n;i++)
			for(int j=0;j<m;j++)
			{
				//char ch;
				cin>>ar[i][j];
			}

		for(int i=0;i<n;i++)
		{
			for(int j=0;j<m;j++)
			{
				if(ar[i][j]!='.')
					continue;
				if(i%2==0)
				{
					if(j%2==0)
						cout<<"W";
					else cout<<"B";
				}
				else
				{
					if(j%2==0)
						cout<<"B";
					else cout<<"W";
				}
			}

			cout<<endl;
		}
	}
	return 0;
}


/*
@Author: Naseef
Chittagong University of Engineering & Technology
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <map>
#include <bitset>
#include <ctime>
#include <cmath>
#include <cassert>
#include <algorithm>
using namespace std;

#define pb(p) push_back(p)
#define fr(i,a,b) for(int i=a;i<b;i++)
#define frd(i,a,b) for(int i=a; i>=b i--)
#define PI 2*acos(0.0)
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()

int MIN (int a, int b) {
  int x= (b>a)?a:b;
  return x;
}

int MAX(int a, int b) {
  int x= (b<a)?a:b;
  return x;
}

#define maxn 10000000

/*vector<int>prime;
__int64 count[maxn+10];
bool visit[maxn+10];

void make_prime(){

        /*for( i=2;i*i<=MAX;i++ ){
        if( ntP[i] ) continue;
        for( j=i*i;j<=MAX;j+=i ) ntP[j] = true;
    int i,j;
    int pos1=sqrt((double)maxn)+1;
    visit[1]=true;
    visit[4]=true;
    visit[6]=true;
    visit[8]=true;
    for(i=3;i<=pos1;i++)
    {
        if(visit[i]==false)
        {
            for(j=i*i;j<=maxn;j=j+i+i)
            visit[j]=true;
        }
    }
    prime.push_back(2);
    for(j=3;j<=maxn;j+=2)
        if( visit[j]==false )prime.push_back(j);
}
*/
typedef long long ll;
const int size = 1000007;
const ll modulo = 1000000007;
const ll inf = 1e18;
const double eps = 1e-6;
ll n,m,a[4000],b[4000],k,n25,n50,n100;

/*
int gcd(int a,int b)
{
    while(b>0)
    {
        a%=b;
        a^=b;
        b^=a;
        a^=b;
    }
    return a;
}

ll lcm(ll a,ll b)
{
    return ((a*b)/gcd(a,b));
}*/

int main()
{
    #ifdef WRITE_IN_FILE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    char ar[100][100];
    while(cin>>n>>m)
    {
        char ar1[2];
        ar1[0]='W';
        ar1[1]='B';

        for(int i=0;i<n;i++)
            for(int j=0;j<m;j++)
            {
                //char ch;
                cin>>ar[i][j];
            }

        for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)
            {
                if(ar[i][j]!='.')
                {
                    cout<<ar[i][j];
                    continue;
                }
                if(i%2==0)
                {
                    if(j%2==0)
                        cout<<"W";
                    else cout<<"B";
                }
                else
                {
                    if(j%2==0)
                        cout<<"B";
                    else cout<<"W";
                }
            }

            cout<<endl;
        }
    }
    return 0;
}


/*
@Author: Naseef
Chittagong University of Engineering & Technology
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <map>
#include <bitset>
#include <ctime>
#include <cmath>
#include <cassert>
#include <algorithm>
using namespace std;

#define pb(p) push_back(p)
#define fr(i,a,b) for(int i=a;i<b;i++)
#define frd(i,a,b) for(int i=a; i>=b i--)
#define PI 2*acos(0.0)
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()

int MIN (int a, int b) {
  int x= (b>a)?a:b;
  return x;
}

int MAX(int a, int b) {
  int x= (b<a)?a:b;
  return x;
}

#define maxn 10000000

/*vector<int>prime;
__int64 count[maxn+10];
bool visit[maxn+10];

void make_prime(){

		/*for( i=2;i*i<=MAX;i++ ){
        if( ntP[i] ) continue;
        for( j=i*i;j<=MAX;j+=i ) ntP[j] = true;
    int i,j;
    int pos1=sqrt((double)maxn)+1;
	visit[1]=true;
	visit[4]=true;
	visit[6]=true;
	visit[8]=true;
    for(i=3;i<=pos1;i++)
	{
		if(visit[i]==false)
		{
			for(j=i*i;j<=maxn;j=j+i+i)
			visit[j]=true;
		}
	}
    prime.push_back(2);
    for(j=3;j<=maxn;j+=2)
        if( visit[j]==false )prime.push_back(j);
}
*/
typedef long long ll;
const int size = 1000007;
const ll modulo = 1000000007;
const ll inf = 1e18;
const double eps = 1e-6;
ll n,m,a[4000],b[4000],k,n25,n50,n100;

/*
int gcd(int a,int b)
{
    while(b>0)
    {
        a%=b;
        a^=b;
        b^=a;
        a^=b;
    }
    return a;
}

ll lcm(ll a,ll b)
{
    return ((a*b)/gcd(a,b));
}*/

int main()
{
    #ifdef WRITE_IN_FILE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
	char ar[100][100];
	while(cin>>n>>m)
	{
		char ar1[2];
		ar1[0]='W';
		ar1[1]='B';

		for(int i=0;i<n;i++)
			for(int j=0;j<m;j++)
			{
				//char ch;
				cin>>ar[i][j];
			}

		for(int i=0;i<n;i++)
		{
			for(int j=0;j<m;j++)
			{
				if(ar[i][j]=='-')
					continue;
				if(i%2==0)
				{
					if(j%2==0)
						cout<<"W";
					else cout<<"B";
				}
				else
				{
					if(j%2==0)
						cout<<"B";
					else cout<<"W";
				}
			}

			cout<<endl;
		}
	}
	return 0;
}


/*
* CF.cpp
*
*  Created on: Jan 30, 2015
*      Author: Sohieb Mohamed ( Deader )
*/

#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<iterator>
#include<cmath>
#include<string>
#include<sstream>
#include<cstring>
#include<ctype.h>
#include<iomanip>
#include<bitset>
#include<stdio.h>
#include<fstream>

// Suppress some compilation warning messages
#define _CRT_SECURE_NO_DEPRECATE 1
#define _CRT_SECURE_NO_WARNINGS 1
#define all(v) ((v).begin()),((v).end())

using namespace std;

typedef string            ss;
typedef long long         ll;
typedef pair <int, int>   ii;
typedef pair<string, int> si;
typedef pair<int, string> is;
typedef vector<ii>       vii;
typedef vector<int>       vi;
typedef vector<vi>       vvi;
typedef vector<string>    vs;
#define INF 1000000000

/*
here you can put your global varibles
*/

char arr[104][104] = { 0 };
int n, m;
int main()
{
    cin >> n >> m;
    for (int i = 1; i <= n;i++)
    for (int j = 1; j <= m; j++)
        cin >> arr[i][j];
    for (int i = 1; i <= n; i++)
    {
        for (int j=1; j <= m; j++)
        {
            if (arr[i][j] == '.')
            {
                if (arr[i - 1][j] != 'B'&&arr[i + i][j] != 'B'&&arr[i][j - 1] != 'B'&&arr[i][j + 1] != 'B')
                    arr[i][j] = 'B';
                else arr[i][j] = 'W';
            }
        }
    }
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= m; j++)
            cout << arr[i][j];
        cout << endl;
    }
    return 0;
}


/*
* CF.cpp
*
*  Created on: Jan 30, 2015
*      Author: Sohieb Mohamed ( Deader )
*/

#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<iterator>
#include<cmath>
#include<string>
#include<sstream>
#include<cstring>
#include<ctype.h>
#include<iomanip>
#include<bitset>
#include<stdio.h>
#include<fstream>

// Suppress some compilation warning messages
#define _CRT_SECURE_NO_DEPRECATE 1
#define _CRT_SECURE_NO_WARNINGS 1
#define all(v) ((v).begin()),((v).end())

using namespace std;

typedef string            ss;
typedef long long         ll;
typedef pair <int, int>   ii;
typedef pair<string, int> si;
typedef pair<int, string> is;
typedef vector<ii>       vii;
typedef vector<int>       vi;
typedef vector<vi>       vvi;
typedef vector<string>    vs;
#define INF 1000000000

int n, m;
ss ans = "BW", arr[105];

int main()
{
    cin >> n >> m;
    for (int i = 0; i < n; i++)
    {
        cin >> arr[i];
        for (int j = 0; j < m; j++)
        {
            if (arr[i][j] == '.') arr[i][j] = ans[(i + j) % 2];
            cout << arr[i][j];
        }
        cout << endl;
    }
}