#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 30;
const long long LINF = 1LL << 60;
const long long MOD = (long long)1e9 + 7;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> ans(n, -1);
  for (int i = 0; i < m; i++) {
    int s, c;
    cin >> s >> c;
    s--;
    if (s == 0 && c == 0) {
      cout << -1 << endl;
      return 0;
    } else if (ans[s] == -1) {
      ans[s] = c;
    } else if (ans[s] != c) {
      cout << -1 << endl;
      return 0;
    }
  }
  if (ans[0] == -1) {
    ans[0] = 1;
  }
  for (int i = 1; i < n; i++) {
    if (ans[i] == -1) {
      ans[i] = 0;
    }
  }
  for (int i = 0; i < n; i++) {
    cout << ans[i];
  }
  cout << endl;
  return 0;
}
