#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> num(n);
  num[0] = -1;
  for (int i = 0; i < (n); i++) num[i] = -1;
  int result = 1;
  for (int i = 0; i < m; i++) {
    int s, c;
    cin >> s >> c;
    if (num[s - 1] == -1)
      num[s - 1] = c;
    else if (num[s - 1] == c)
      continue;
    else {
      result = 0;
      break;
    }
  }
  for (int i = 0; i < (n); i++) {
    if (num[0] == -1) num[0] = 1;
    if (num[0] == 0) result = 0;
    if (num[i] == -1) num[i] = 0;
  }
  if (result == 0)
    cout << -1 << endl;
  else {
    for (int i = 0; i < (n); i++) cout << num[i];
    cout << endl;
  }
}
