#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int s, c;
  int min[n + 1];
  bool ans = true;
  for (int i = 1; i <= n; i++) {
    min[i] = 10;
  }
  for (int i = 1; i <= m; i++) {
    cin >> s >> c;
    if (s == 1 && c == 0) {
      ans = false;
      continue;
    }
    if (c < min[s]) {
      min[s] = c;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (min[i] == 10) {
      min[i] = 0;
    }
  }
  if (min[1] == 0) {
    ans = false;
  }
  if (m == 0) {
    ans = true;
    min[1] = 1;
    for (int i = 2; i <= n; i++) {
      min[i] = 0;
    }
    if (n == 1) {
      min[1] = 0;
    }
  }
  if (ans) {
    for (int i = 1; i <= n; i++) {
      cout << min[i];
    }
  } else {
    cout << "-1";
  }
}
