#include <bits/stdc++.h>
using namespace std;
int bin_search(int ele, vector<pair<int, int> > arr) {
  int l = 0, r = arr.size() - 1, mid = 0;
  while (l <= r) {
    mid = l + (r - l) / 2;
    if (arr[mid].first == ele) {
      return arr[mid].second;
    } else if (arr[mid].first > ele) {
      r = mid - 1;
    } else {
      l = mid + 1;
    }
  }
  return mid;
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<pair<int, int> > arr(m);
  int i;
  vector<int> num(n, -1);
  bool flag = true;
  for (i = 0; i < m; ++i) {
    cin >> arr[i].first >> arr[i].second;
    if (arr[i].first > n) {
      flag = false;
    }
    if (arr[i].first == 1 && arr[i].second == 0 && n != 1) {
      flag = false;
    }
    if (arr[i].first <= n && num[arr[i].first - 1] == -1) {
      num[arr[i].first - 1] = arr[i].second;
    } else if (arr[i].first <= n && num[arr[i].first - 1] != arr[i].second) {
      flag = false;
    }
  }
  if (!flag) {
    cout << "-1";
    return 0;
  }
  if (num[0] == -1) {
    num[0] = 1;
  }
  for (i = 1; i < n; ++i) {
    if (num[i] == -1) {
      num[i] = 0;
    }
  }
  for (i = 0; i < n; ++i) {
    cout << num[i];
  }
}
