#include <iostream>
#include <cstdlib>
#include <vector>
#include <cmath>
#include <string>

using std::string;
using std::cout;
using std::cin;
using std::vector;
using std::endl;

class Set {
 public:

  explicit Set(const vector<int64_t> &vector) {
    for (auto x: vector) {
      this->Add(x);
    }
  }

  Set() {
  }

  Set Union(const Set &other) const {
    std::vector<int64_t> tmp;
    tmp.insert(tmp.end(), this->vec.begin(), this->vec.end());
    tmp.insert(tmp.end(), other.vec.begin(), other.vec.end());
    return Set(tmp);
  }

  Set Intersection(const Set &other) const {
    Set new_set;
    bool used = false;
    for (auto x: this->vec) {
      for (auto y: other.vec) {
        if (x == y) {
          new_set.vec.push_back(x);
          used = true;
        }
      }
      if (used) break;
    }
    return new_set;
  }

  Set Difference(const Set &other) const {
    Set new_set;
    bool used;
    for (auto x: this->vec) {
      used = false;
      for (auto y: other.vec) {
        if (x == y) {
          used = true;
          break;
        }
      }
      if (!used) {
        new_set.vec.push_back(x);
      }
    }
    return new_set;
  }

  Set SymmetricDifference(const Set &other) const {
    Set new_set1 = this->Difference(other);
    Set new_set2 = other.Difference(*this);
    return new_set1.Union(new_set2);
  }

  void Add(int64_t num) {
    if (this->vec.size()) {
      auto it = std::lower_bound(this->vec.begin(), this->vec.end(), num);
      if (*it != num) {
        this->vec.insert(it, num);
      }
    } else {
      this->vec.push_back(num);
    }
  }

  void Remove(int64_t num) {
    auto it = std::find(this->vec.begin(), this->vec.end(), num);
    if (it != this->vec.end())
      this->vec.erase(it);
  }

  bool Contains(int64_t num) const {
    for (auto x: this->vec) {
      if (x == num) return true;
    }
    return false;
  }

  vector<int64_t> Data() const {
    return this->vec;
  }

  vector<int64_t> vec;
};