#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  int digits[4] = {-1, -1, -1, -1};
  for (int i = 0; i < m; i++) {
    int s, c;
    cin >> s >> c;
    if (digits[s - 1] != -1 && digits[s - 1] != c) {
      cout << "-1\n";
      return 0;
    }
    digits[s - 1] = c;
  }
  if (digits[0] == 0) {
    cout << "-1\n";
    return 0;
  }
  if (digits[0] == -1) digits[0] = 1;
  for (int i = 1; i < n; i++)
    if (digits[i] == -1) digits[i] = 0;
  for (int i = 0; i < n; i++) cout << digits[i];
  cout << "\n";
  return 0;
}
