#include <bits/stdc++.h>
using namespace std;
void YES(bool flag) { cout << (flag ? "YES" : "NO") << endl; }
void Yes(bool flag) { cout << (flag ? "Yes" : "No") << endl; }
void yes(bool flag) { cout << (flag ? "yes" : "no") << endl; }
const int INF = 1e7;
const long long MOD = 1e9 + 7;
int n, m;
string ans = "";
bool flag = true;
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    ans += '\0';
  }
  for (int i = 0; i < m; i++) {
    int s, c;
    cin >> s >> c;
    if (ans[s - 1] == '\0') {
      ans[s - 1] = '0' + c;
    } else if (ans[s - 1] != '0' + c) {
      flag = false;
    }
  }
  if (flag && ans[0] != '0') {
    for (int i = 0; i < n; i++) {
      if (ans[i] == '\0') {
        if (i == 0 && n != 1)
          ans[i] = '1';
        else
          ans[i] = '0';
      }
    }
    cout << ans << endl;
  } else {
    cout << -1 << endl;
  }
  return 0;
}
