#include <bits/stdc++.h>
using namespace std;
int main() {
  string ans = "";
  int arr[20] = {0}, max = -1;
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    int tmp, tmp1;
    cin >> tmp >> tmp1;
    if (tmp1 == 0) tmp1 = -10;
    if (arr[tmp] != 0 && arr[tmp] != tmp1) {
      cout << -1;
      return 0;
    }
    arr[tmp] = tmp1;
    if (max <= tmp) {
      max = tmp;
    }
  }
  if (arr[1] == -10 && n > 1) {
    cout << -1;
    return 0;
  } else {
    for (int i = 1; i <= max; ++i) {
      if (arr[i] == -10)
        ans += '0';
      else if (arr[i] != 0)
        ans += to_string(arr[i]);
      else
        ans += '0';
    }
  }
  if (ans.length() > n)
    cout << -1;
  else if (ans.length() == n)
    cout << ans;
  else {
    int i = 0;
    while (ans[i] == '0') {
      ans[i] = '1';
      i++;
    }
    for (int i = ans.length(); i < n; ++i) {
      ans += '0';
    }
    cout << ans;
  }
  return 0;
}
