#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(0);
  int n, m;
  cin >> n >> m;
  vector<int> digit(n, -1);
  bool found = true;
  for (int i = 0; i < m; i++) {
    int dig, val;
    cin >> dig >> val;
    dig--;
    if (dig >= n) {
      found = false;
      continue;
    }
    if (digit[dig] == -1)
      digit[dig] = val;
    else if (digit[dig] != val)
      found = false;
  }
  if (!found) {
    cout << -1 << endl;
    return 0;
  }
  if (digit[0] == 0) {
    if (n == 1)
      cout << 0 << endl;
    else
      cout << -1 << endl;
    return 0;
  }
  string s;
  if (m == 0) {
    s += '1';
    for (int i = 1; i < n; i++) s += '0';
    cout << s << '\n';
    return 0;
  }
  for (int i = 0; i < n; i++) {
    if (digit[i] != -1) {
      s += digit[i] + '0';
    } else
      s += '0';
  }
  if (s[0] == '0') s[0] = '1';
  cout << s << endl;
  return 0;
}
