#include <bits/stdc++.h>
using namespace std;
long long int N = 100000, M = 100000;
long long int MOD = 1000000007;
long long int gcd(long long int a, long long int b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
long long int ncr(long long int n, long long int r) {
  if (n == 1 || r == 0) return 1;
  if (r > n / 2) r = n - r;
  long long int ans = 1;
  for (long long int i = 1; i <= r; i++) {
    ans = ((ans * n) / i);
    n--;
  }
  return ans;
}
int main() {
  long long int n, m;
  cin >> n >> m;
  long long int s[m + 1], c[m + 1];
  for (long long int i = 0; i < m; i++) cin >> s[i] >> c[i];
  long long int a[n + 1];
  for (long long int i = 0; i < n; i++) a[i] = -1;
  for (long long int i = 0; i < m; i++) a[s[i] - 1] = c[i];
  for (long long int i = 0; i < n; i++) {
    if (a[i] == -1) a[i] = 0;
  }
  if (a[0] == 0 && n != 1)
    cout << "-1";
  else {
    for (long long int i = 0; i < n; i++) cout << a[i];
  }
}
