#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M, result;
  cin >> N >> M;
  int ans[3] = {0, 0, 0};
  vector<int> vec;
  vec.resize(M * 2);
  for (int i = 0; i < M * 2; i++) {
    cin >> vec[i];
  }
  for (int i = 0; i < M * 2; i += 2) {
    int index = vec[i] - 1;
    ans[index] = vec[i + 1];
  }
  result = ans[0] * 100 + ans[1] * 10 + ans[2] * 1;
  cout << result << endl;
}
