#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  char ch[100];
  memset(ch, '0', sizeof ch);
  if (n == 1 && m == 0) {
    cout << "0" << endl;
    exit(0);
  }
  if (n == 1 && m == 1) {
    int t;
    cin >> t;
    cout << t << endl;
    exit(0);
  }
  for (int i = 0; i < m; i++) {
    int tx, ty;
    cin >> tx >> ty;
    if (ch[tx] != '0' && ch[tx] != ty + '0') {
      cout << "-1" << endl;
      exit(0);
    }
    if (n != 1 && tx == 1 && ty == 0) {
      cout << "-1" << endl;
      exit(0);
    }
    ch[tx] = ty + '0';
  }
  if (ch[1] == '0') {
    ch[1] = '1';
  }
  for (int i = 1; i <= n; i++) {
    cout << ch[i];
  }
  return 0;
}
