#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, m;
  cin >> n >> m;
  vector<long long> ans(n, -1);
  long long s, c, flg = 1;
  for (long long i = 0; i < m; i++) {
    cin >> s >> c;
    s--;
    if (ans[s] == -1)
      ans[s] = c;
    else if (ans[s] != c)
      flg = 0;
    if (s == 0 && c == 0 && n > 1) flg = 0;
  }
  if (flg) {
    for (long long i = 0; i < n; i++) {
      if (ans[i] == -1) {
        if (i == 0)
          ans[i] = 1;
        else
          ans[i] = 0;
      }
      cout << ans[i];
    }
    cout << "\n";
  } else
    cout << -1 << "\n";
}
