#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
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;
    if (ans[s - 1] != -1 && ans[s - 1] != c) {
      cout << -1 << endl;
      return 0;
    }
    ans[s - 1] = c;
  }
  if (n == 1) {
    cout << (ans[0] == -1 ? ans[0] : 0) << endl;
    return 0;
  }
  for (int i = 0; i < n; ++i) {
    if (i == 0)
      cout << (ans[i] != -1 ? ans[i] : 1);
    else
      cout << (ans[i] != -1 ? ans[i] : 0);
  }
  cout << endl;
  return 0;
}
