#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vi s(m), c(m);
  for (int i = 0; i < (m); ++i) cin >> s[i] >> c[i];
  bool ans;
  vi num(n, 0);
  for (int i = 0; i < (m); ++i) {
    num[s[i] - 1] = c[i];
  }
  for (int i = 0; i < (m); ++i) {
    if (num[s[i] - 1] != 0) chmin(num[s[i] - 1], c[i]);
  }
  if (num[0] == 0) {
    num.resize(1);
    num[0] = NIL;
  }
  for (int i = 0; i < (num.size()); ++i) cout << num[i];
  cout << endl;
  return 0;
}
