#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  int s[n];
  memset(s, -1, sizeof s);
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    a--;
    if (s[a] != -1 && s[a] != b) return cout << -1, 0;
    s[a] = b;
  }
  if (s[0] == -1) s[0] = 1;
  if (s[1] == -1) s[1] = 0;
  if (s[2] == -1) s[2] = 0;
  if (n > 1 && s[0] == 0) return cout << -1, 0;
  for (int i = 0; i < n; ++i) cout << s[i];
}
