#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  ll n, m;
  cin >> n >> m;
  vector<char> num(n, 'x');
  ll s, c;
  for (int i = 0; i < m; i++) {
    cin >> s >> c;
    s--;
    if (num[s] == 'x' || num[s] == '0' + c) {
      if (s == 0 && c == 0) {
        cout << -1 << endl;
        return 0;
      }
      num[s] = '0' + c;
    } else {
      cout << -1 << endl;
      return 0;
    }
  }
  for (int i = 0; i < n; i++) {
    if (num[i] == 'x') {
      if (i == 0) {
        num[i] = '1';
      } else {
        num[i] = '0';
      }
    }
  }
  for (int i = 0; i < n; i++) cout << num[i];
  cout << endl;
  return 0;
}
