#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;
int main() {
  int n, m;
  cin >> n >> m;
  string s = string(n, '*');
  for (int i = 0; i < m; ++i) {
    int place;
    char numb;
    cin >> place >> numb;
    if ((s[place - 1] != '*' && s[place - 1] != numb) ||
        (place == 1 && numb == '0')) {
      s = "-1";
    } else {
      s[place - 1] = numb;
    }
  }
  if (s[0] == '*') s[0] = '1';
  for (int i = 1; i < n; ++i) {
    if (s[i] == '*') s[i] = '0';
  }
  cout << s;
  return 0;
}
