#include <bits/stdc++.h>
using namespace std;
const int maxn = 11;
int n, m, digit[maxn], book[maxn];
int main() {
  memset(digit, 0, sizeof(digit));
  memset(book, 0, sizeof(book));
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int s, c;
    cin >> s >> c;
    digit[s] = c;
    if (book[s] == 0)
      book[s] = c;
    else {
      if (book[s] != c) {
        cout << "-1" << endl;
        return 0;
      }
    }
  }
  if (n == 1)
    cout << digit[1] << endl;
  else {
    if (book[1] == 0) digit[1] = 1;
    if (digit[1] == 0)
      cout << "-1" << endl;
    else {
      for (int i = 1; i <= n; i++) cout << digit[i];
      cout << endl;
    }
  }
  return 0;
}
