#include <bits/stdc++.h>
using namespace std;
int nn[3] = {10, 10, 10};
int main() {
  int n, m;
  cin >> n >> m;
  int kg = 0;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    if (nn[a - 1] != 10 && nn[a - 1] != b) kg = 1;
    nn[a - 1] = b;
  }
  if (nn[0] == 0) {
    cout << -1;
    return 0;
  }
  int kk = 0, gg = 0;
  for (int i = n - 1; i >= 0; i--)
    if (nn[i] != 0 && nn[i] != 10) gg = 1;
  if (kg == 1) {
    cout << -1;
    return 0;
  }
  if (!gg) {
    cout << 1;
    for (int i = 1; i < n; i++) cout << 0;
    return 0;
  }
  if (nn[0] == 10) nn[0] = 1;
  for (int i = 1; i < n; i++)
    if (nn[i] == 10) nn[i] = 0;
  for (int i = 0; i < n; i++) cout << nn[i];
  return 0;
}
