#include <bits/stdc++.h>
using namespace std;
int digits[6];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m, x, y;
  cin >> n >> m;
  memset(digits, -1, sizeof(digits));
  for (int i = 1; i <= m; ++i) {
    cin >> x >> y;
    if (digits[x] == -1 || digits[x] == y)
      digits[x] = y;
    else
      return cout << -1, 0;
  }
  for (int i = 1; i <= n; ++i) {
    if (i == 1 && digits[i] == -1)
      digits[i] = 1;
    else if (digits[i] == -1)
      digits[i] = 0;
  }
  if (n > 1 && digits[1] == 0) return cout << -1, 0;
  for (int i = 1; i <= n; ++i) cout << digits[i];
  return 0;
}
