#include <bits/stdc++.h>
using namespace std;
static int fast_io = []() {
  std::ios::sync_with_stdio(false);
  cin.tie(nullptr);
  return 0;
}();
int main() {
  int n, m;
  cin >> n >> m;
  string start(n, '*');
  for (int i = 0; i < m; i++) {
    int pos;
    char value;
    cin >> pos >> value;
    if (start[pos - 1] != value) {
      if (start[pos - 1] != '*') {
        start = "-1";
        break;
      } else {
        start[pos - 1] = value;
      }
    }
  }
  if (n == 1 && start == "0") {
    cout << "-1"
         << "\n";
    return 0;
  }
  for (int i = 0; i < n; i++) {
    if (i == 0 && start[i] == '0') {
      start = "-1";
      break;
    } else if (i == 0 && start[i] == '*') {
      start[i] = '1';
    } else if (start[i] == '*') {
      start[i] = '0';
    }
  }
  cout << start << "\n";
}
