import java.util.*;

interface IDictionary<K, V> {
    void insert(K key, V value);
    V get(K key);
    int size();
    boolean isEmpty();
}

class Entry<K, V> {
    K key;
    V value;
    public Entry(K key, V value) {
        this.key = key;
        this.value = value;
    }

    @Override
    public String toString() {
        return key.toString() + "#" + value.toString();
    }
}

class Dictionary<K, V> implements IDictionary<K, V> {
    private int size = 0;
    private int tableSize = 10;
    private Object table[];
    public Dictionary() {
        table = new Object[tableSize];
    }

    public void insert(K key, V value) {
        int hash = key.hashCode();
        hash = (hash & 0x7fffffff) % tableSize;
        if(table[hash] != null) {
            System.out.println("udpate 😂");
            table[hash] = new Entry(key, value);
        } else {
            System.out.println("Inserted 😁");
            table[hash] = new Entry(key, value);
            size += 1;
        }
        // System.out.println(hash);
        
    }
    
    public V get(K key) {
        int hash = key.hashCode();
        hash = (hash & 0x7fffffff) % tableSize;
        Entry e = (Entry)table[hash];
        if(e == null) {
            return null;
        }
        return (V)e.value;
    }
    
    @Override
    public int size() {
        return size;
    }

    public boolean isEmpty() {
        return size == 0;
    }
}

class Main {
    public static void main(String[] args) {
        Dictionary<String, String> dictionary = new Dictionary<>();
        dictionary.insert("AMITH", "K");
        dictionary.insert("AMITH", "K");
        System.out.println(dictionary.size());
        dictionary.insert("LUFFY", "K");
        System.out.println(dictionary.size());
        System.out.println(dictionary.get("LUFFY"));
        dictionary.insert("LUFFY", "AMITH");
        System.out.println(dictionary.size());
        System.out.println(dictionary.get("LUFFY"));
    }
}