#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, t;
  cin >> n >> t;
  string p;
  for (int i = 0; i < n; i++) p.push_back('A');
  for (int i = 0; i < t; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    if (p[a] == 'A')
      p[a] = (b + '0');
    else if (p[a] - '0' != b) {
      cout << -1 << endl;
      return 0;
    }
  }
  if (n > 1 && p[0] == '0') {
    cout << -1 << endl;
    return 0;
  }
  for (int i = 0; i < n; i++)
    if (p[i] == 'A') {
      if (i)
        cout << '0';
      else
        cout << 1;
    } else
      cout << p[i];
  cout << endl;
  return 0;
}
