#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  bool a = true;
  int b;
  char c;
  string s(n, 'c');
  for (int i = 0; i < m; ++i) {
    cin >> b >> c;
    if (s[b - 1] == 'c' || s[b - 1] == c) {
      s[b - 1] = c;
    } else {
      a = false;
    }
  }
  if (s[0] == '0') a = false;
  if (a) {
    for (int i = 0; i < n; ++i) {
      if (i == 0) {
        (s[i] == 'c') ? cout << 1 : cout << s[i];
      } else {
        (s[i] == 'c') ? cout << 0 : cout << s[i];
      }
    }
  } else {
    cout << -1;
  }
  cout << "\n";
  return 0;
}
