#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n, m, s, c;
  cin >> n >> m;
  string st(n, 'x');
  for (size_t i = 0; i < m; i++) {
    cin >> s >> c;
    s--;
    if (st[s] != 'x' && st[s] != ('0' + c)) {
      cout << -1 << endl;
      return 0;
    }
    st[s] = ('0' + c);
  }
  if (st[0] == '0') {
    cout << -1 << endl;
    return 0;
  }
  if (st[0] == 'x') st[0] = '1';
  for (auto& i : st) {
    if (i == 'x') i = '0';
  }
  cout << st << endl;
  return 0;
}
