#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e9;
int main() {
  int n, m;
  cin >> n >> m;
  int s[m], c[m];
  map<int, int> mp;
  for (int i = 0; i < (int)(m); i++) {
    cin >> s[i] >> c[i];
    if (s[i] > n) {
      cout << -1 << endl;
      return 0;
    }
    if (mp[s[i]]) {
      if (mp[s[i]] != c[i]) {
        cout << -1 << endl;
        return 0;
      }
    } else {
      mp[s[i]] = c[i];
    }
    if (n >= 2 && s[i] == 1 && c[i] == 0) {
      cout << -1 << endl;
      return 0;
    }
  }
  string ans(n, '0');
  for (auto i : mp) {
    int d = i.first - 1;
    int num = i.second;
    ans[d] = char(num + '0');
  }
  if (ans[0] == '0') ans[0] = '1';
  cout << ans << endl;
  return 0;
}
