#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  string s = "";
  for (int i = 0; i < n; i++) s = s + ".";
  int check = 1;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    if (s[a - 1] != '.' && s[a - 1] - '0' != b) check = 0;
    s[a - 1] = '0' + b;
  }
  if (s[0] == '0' && n > 1) check = 0;
  if (check == 0) {
    cout << "-1\n";
  } else {
    for (int i = 0; i < n; i++) {
      if (s[i] == '.') s[i] = '1';
    }
    cout << s;
  }
}
