#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int main() {
  int n, m;
  cin >> n >> m;
  int arr[n];
  for (int i = 0; i < n; ++i) {
    arr[i] = -1;
  }
  int s, c;
  std::vector<int> mark(n, -1);
  for (int i = 0; i < m; ++i) {
    cin >> s >> c;
    s--;
    if (mark[s] != -1 && mark[s] != c) {
      cout << -1;
      return 0;
    } else {
      mark[s] = c;
      arr[s] = c;
    }
  }
  if (arr[0] == 0) {
    cout << -1;
    return 0;
  }
  bool get_first_no = false;
  if (n == 1 && m == 0) {
    cout << 0;
    return 0;
  }
  for (int i = 0; i < n; ++i) {
    if (arr[i] != -1) {
      get_first_no = true;
      cout << arr[i];
    } else if (get_first_no) {
      cout << 0;
    } else {
      cout << 1;
      get_first_no = true;
    }
  }
  return 0;
}
