#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;
  map<int, char> data;
  string s = string(n, '*');
  for (int i = 0; i < m; ++i) {
    int k;
    char c;
    cin >> k >> c;
    if (data.find(k) != data.end() && data.at(k) != c) {
      s = "-1";
    } else {
      data.insert(pair<int, char>(k, c));
    }
  }
  if (s == "-1") {
    cout << -1;
  } else {
    for (int i = 0; i < n; ++i) {
      if (data.find(i + 1) != data.end()) {
        s[i] = data.at(i + 1);
        if (i == 0 && data.at(i + 1) == '0') {
          s = "-1";
          break;
        }
      } else {
        if (i == 0)
          s[i] = '1';
        else
          s[i] = '0';
      }
    }
    cout << s;
  }
  return 0;
}
