#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, s, c;
  cin >> n >> m;
  vector<int> v(n, -1);
  for (int i = 0; i < m; ++i) {
    cin >> s >> c;
    s--;
    if (s == 0 && c == 0) {
      cout << -1 << '\n';
      return 0;
    }
    if (v[s] == -1)
      v[s] = c;
    else {
      if (v[s] != c) {
        cout << -1 << '\n';
        return 0;
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    if (v[0] == -1)
      v[0] = 1;
    else if (i != 0 && v[i] == -1)
      v[i] = 0;
    cout << v[i];
  }
  cout << '\n';
  return 0;
}
