/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <cmath>
#include <cstdint>
#include <iostream>
#include <string>
#include <cmath>
#include <cstring>

constexpr int32_t kMaxKeyLength = 12;
constexpr int64_t kHashTableSize = 1046527;  //!< Prime number
constexpr int8_t kInvalid = 0;
constexpr int8_t kValid = 1;
constexpr int64_t kMaxIterationHash = 1046527;

void CallDictionary(std::istream &input_stream) noexcept;

enum class InstructionType : int32_t { kInsert = 0, kFind, kInvalid };

enum DecodedValue : int64_t { kNone = 0, kA, kC, kG, kT, kBase };

InstructionType JudgeInstructionType(const std::string &str);

class Key {
 public:
  Key() noexcept;
  ~Key() noexcept;

  Key &operator=(const Key &rhs) noexcept;
  bool Equals(const Key &obj) const noexcept;
  std::string GetKey() const noexcept;
  bool IsValid() const noexcept;
  bool IsInvalid() const noexcept;

  void SetKeyC(const char *const key) noexcept;
  void SetKeyS(const std::string key) noexcept;

 private:
  Key(Key &&obj) noexcept = delete;
  Key(const Key &obj) noexcept = delete;
  Key &operator=(Key &&rhs) noexcept = delete;
  void Reset() noexcept;

 private:
  char key_string_[kMaxKeyLength + 1];
};

class Dictionary {
 public:
  Dictionary() noexcept;
  ~Dictionary() noexcept;
  void Insert(const std::string &key);
  bool WasFound(const std::string &key) const;

 private:
  Dictionary(const Dictionary &obj) noexcept = delete;
  Dictionary &operator=(const Dictionary &obj) noexcept = delete;
  Dictionary(Dictionary &&obj) = delete;
  Dictionary &operator=(Dictionary &&obj) = delete;

  static int64_t GetDecodedKey(const std::string &key);
  static int64_t CalculateHash(const int64_t decoded_key, const int64_t index_iteration);
  static int64_t DecodeOneChar(const char c);
  static int64_t Hash1(const int64_t decoded_key);
  static int64_t Hash2(const int64_t decoded_key);

 private:
  Key hash_table_[kHashTableSize];
};


void CallDictionary(std::istream &input_stream) noexcept {
  input_stream.tie(0);
  std::ios::sync_with_stdio(false);
  Dictionary *dictionary = new Dictionary();
  try {
    int32_t number_of_instructions;
    input_stream >> number_of_instructions;
    for (int32_t index_instruction = 0; index_instruction < number_of_instructions; ++index_instruction) {
      std::string instruction_str;
      input_stream >> instruction_str;
      const InstructionType instruction = JudgeInstructionType(instruction_str);
      std::string key;
      input_stream >> key;
      switch (instruction) {
        case InstructionType::kInsert:
          dictionary->Insert(key);
          break;
        case InstructionType::kFind:
          if (dictionary->WasFound(key)) {
            std::cout << "yes" << std::endl;
          } else {
            std::cout << "no" << std::endl;
          }
          break;
        case InstructionType::kInvalid:
          std::cerr << "ERROR: CallDictionary(): Invalid instruction type." << std::endl;
          break;
      }
    }
  } catch (...) {
    std::cerr << "ERROR: CallDictionary()" << std::endl;
  }
  delete dictionary;
}

InstructionType JudgeInstructionType(const std::string &str) {
  InstructionType instruction_type;
  if (str == "insert") {
    instruction_type = InstructionType::kInsert;
  } else if (str == "find") {
    instruction_type = InstructionType::kFind;
  } else {
    std::cerr << "ERROR: JudgeInstructionType(): Invalid input data. " << str << std::endl;
    throw 1;
  }
  return instruction_type;
}

// ****************************************************

Key::Key() noexcept {
  Reset();
}

void Key::SetKeyC(const char *const key) noexcept {
  strncpy(key_string_, key, kMaxKeyLength);
}

void Key::SetKeyS(const std::string key) noexcept {
  strncpy(key_string_, key.c_str(), kMaxKeyLength);
}

Key::~Key() noexcept {}



Key &Key::operator=(const Key &rhs) noexcept {
  if (this != &rhs) {
    strncpy(this->key_string_, rhs.key_string_, kMaxKeyLength);
  }
  return *this;
}

std::string Key::GetKey() const noexcept {
  return std::string(key_string_);
}

bool Key::Equals(const Key &obj) const noexcept {
  return (IsValid() && (strcmp(key_string_, obj.key_string_) == 0));
}

bool Key::IsValid() const noexcept {
  return (strlen(key_string_) != 0);
}

bool Key::IsInvalid() const noexcept {
  return (strlen(key_string_) == 0);
}

void Key::Reset() noexcept {
  for (char &c : key_string_) {
    c = '\0';
  }
}

// ****************************************************

Dictionary::Dictionary() noexcept {}
Dictionary::~Dictionary() noexcept {}

void Dictionary::Insert(const std::string &key) {
  try {
    const int64_t decoded_key = GetDecodedKey(key);
    for (int64_t index_iteration = 0; index_iteration < kMaxIterationHash; ++index_iteration) {
      const int64_t hash_value = CalculateHash(decoded_key, index_iteration);

      if ((hash_value < 0) || (hash_value >= kHashTableSize)) {
        std::cerr << "ERROR: Insert(): Invalid hash value. " << hash_value << std::endl;
        throw 1;
      }
      Key ckey;
      ckey.SetKeyS(key);
      if (hash_table_[hash_value].Equals(ckey)) {
        // Key overwrapping
        break;
      } else if (hash_table_[hash_value].IsInvalid()) {
        Key ckey;
        ckey.SetKeyS(key);
        hash_table_[hash_value] = ckey;
        break;
      }
    }
  } catch (...) {
    std::cerr << "ERROR: Insert()" << std::endl;
    throw;
  }
}

bool Dictionary::WasFound(const std::string &key) const {
  bool was_found = false;
  try {
    const int64_t decoded_key = GetDecodedKey(key);
    for (int64_t index_iteration = 0; index_iteration < kMaxIterationHash; ++index_iteration) {
      const int64_t hash_value = CalculateHash(decoded_key, index_iteration);

      if ((hash_value < 0) || (hash_value >= kHashTableSize)) {
        std::cerr << "ERROR: WasFound(): Invalid hash value. " << hash_value << std::endl;
        throw 1;
      }
      Key current_key;
      current_key = hash_table_[hash_value];
      Key ckey;
      ckey.SetKeyS(key);
      if (current_key.Equals(ckey)) {
        was_found = true;
        break;
      } else if (current_key.IsInvalid()) {
        was_found = false;
        break;
      }
    }
  } catch (...) {
    std::cerr << "ERROR: WasFound()" << std::endl;
    throw;
  }
  return was_found;
}

int64_t Dictionary::CalculateHash(const int64_t decoded_key, const int64_t index_iteration) {
  const int64_t hash_value = (Hash1(decoded_key) + index_iteration * Hash2(decoded_key)) % kHashTableSize;
  return hash_value;
}

int64_t Dictionary::GetDecodedKey(const std::string &key) {
  if ((key.size() <= 0) || (key.size() > kMaxKeyLength)) {
    std::cerr << "ERROR: GetHash(): Invalid input key. " << key << std::endl;
    throw 1;
  }
  int64_t decoded_key = 0;
  int64_t val_exp = 1;
  for (int64_t digit = static_cast<int64_t>(key.size()) - 1; digit >= 0; --digit) {
    const int64_t cval = DecodeOneChar(key[digit]);
    decoded_key += val_exp * cval;
    val_exp *= kBase;
  }
  return decoded_key;
}

int64_t Dictionary::Hash1(const int64_t decoded_key) {
  return (decoded_key % kHashTableSize);
}

int64_t Dictionary::Hash2(const int64_t decoded_key) {
  return (1 + (decoded_key % (kHashTableSize - 1)));
}

int64_t Dictionary::DecodeOneChar(const char c) {
  int64_t value;
  switch (c) {
    case 'A':
      value = kA;
      break;
    case 'C':
      value = kC;
      break;
    case 'G':
      value = kG;
      break;
    case 'T':
      value = kT;
      break;
    default:
      std::cerr << "ERROR: DecodeOneChar(): Invalid input char. " << c << std::endl;
      throw 1;
      break;
  }
  return value;
}
int main(int argc, char *argv[]) {
  try {
    CallDictionary(std::cin);
  } catch (...) {
    std::cerr << "ERROR: main()" << std::endl;
  }
  return 0;
}



Measured memory_bytes: 15940