#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, m;
  cin >> n >> m;
  vector<char> ans(n, '9');
  vector<int> a(n);
  int mn = 1e5;
  for (int i = 0; i < m; i++) {
    int x;
    char c;
    cin >> x >> c;
    mn = min(mn, x - 1);
    if (ans[x - 1] > c) {
      if (x == 1 && c == '0') continue;
      ans[x - 1] = c;
    }
    a[x - 1]++;
  }
  if (n > 1 && !a[0]) {
    cout << -1;
    return;
  }
  for (int i = 0; i < mn; i++) {
    if (!a[i]) {
      ans[i] = '1';
    }
  }
  for (int i = mn + 1; i < n; i++) {
    if (!a[i]) {
      ans[i] = '0';
    }
  }
  for (auto c : ans) {
    cout << c;
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  solve();
  return 0;
}
