#include <bits/stdc++.h>
int main() {
  int N = 0;
  std::cin >> N;
  int M = 0;
  std::cin >> M;
  int* s = new int[M];
  int* c = new int[M];
  for (int i = 0; i < M; ++i) {
    int temp = 0;
    std::cin >> temp;
    s[i] = temp;
    std::cin >> temp;
    c[i] = temp;
  }
  int* ans = new int[N];
  for (int i = 0; i < N; ++i) {
    ans[i] = 0;
  }
  for (int i = 0; i < M - 1; ++i) {
    for (int j = i + 1; j < M; ++j) {
      if (s[i] > s[j]) {
        int tempS = s[i];
        int tempC = c[i];
        s[i] = s[j];
        c[i] = c[j];
        s[j] = tempS;
        c[j] = tempC;
      }
    }
  }
  for (int i = 0; i < M - 1; ++i) {
    for (int j = i + 1; j < M; ++j) {
      if (s[i] == s[j] && c[i] > c[j]) {
        int tempC = c[i];
        c[i] = c[j];
        c[j] = tempC;
      }
    }
  }
  for (int i = 0; i < M; ++i) {
    if (ans[s[i] - 1] == 0) {
      ans[s[i] - 1] = c[i];
    }
  }
  for (int i = 0; i < N; ++i) {
    std::cout << ans[i];
  }
  delete[] ans;
  delete[] c;
  delete[] s;
  return 0;
}
