#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define TABLE_SIZE 10
#define MAX_VALUE_LEN 30
typedef struct Node{
    int key;
    char value[MAX_VALUE_LEN + 1];
    struct Node* next;
}Node;
Node* hashTable[TABLE_SIZE];
int hash(int key){
    return key % TABLE_SIZE;
}
void addElement(int key, char value[]){
    if(key < 0){
        printf("Invalid input\n");
        return;
    }
    int index = hash(key);
    Node* newNode = (Node*)malloc(sizeof(Node));
    newNode->key = key;
    strcpy(newNode->value, value);
    newNode->next = NULL;
    if(hashTable[index] == NULL){
        hashTable[index] == newNode;
    }else{
        Node* temp = hashTabe[index];
        while(temp->next != NULL)
            temp = temp->next;
        temp->next = newNode;
    }
    printf("%d %s\n", key, value);
}
void findElement(int key){
    if(key < 0){
        printf("Invalid input. \n");
        return;
    }
    int index = hash(key);
    Node* temp = hashTable[index];
    while(temp != NULL){
        if(temp->key == key){
            printf("%s\n", temp->value);
            return;
        }
        temp = temp->next;
    }
    printf("Element not found. \n");
}
int main(){
    int n;
    scanf("%d", &n);
    for(int i = 0; i < TABLE_SIZE; i++)
        hashTable[i] = NULL;
    for(int i = 0; i < n; i++){
        char command[10];
        int key;
        char value[MAX_VALUE_LEN + 1];
        scanf("%s", command);
        if(strcmp(command, "ADD") == 0){
            scanf("%d %s", &key, value);
            addElement(key, value);
        }else if(strcmp(command, "FIND") == 0){
            scanf("%d", &key);
            findElement(key);
        }
    }
    return 0;
}