#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = {0, 1, 0, -1};
const int dj[] = {1, 0, -1, 0};
template <typename T>
T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
template <typename T>
T lcm(T a, T b) {
  return a * b / gcd(a, b);
}
template <typename T>
int finder(vector<T> vec, T number) {
  auto itr = find(vec.begin(), vec.end(), number);
  size_t index = distance(vec.begin(), itr);
  if (index != vec.size())
    return 1;
  else
    return 0;
}
long long frac(long long n) {
  if (n == 0) return 1;
  return (n * frac(n - 1)) % MOD;
}
int main(int argc, char** argv) {
  long long ans = 0;
  long long n, m;
  cin >> n >> m;
  int d[n + 1];
  memset(d, ~0, sizeof(d));
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    if ((d[a] != -1 && d[a] != b) || (a == 1 && b == 0) || a > n) {
      cout << "-1\n";
      return 0;
    }
    d[a] = b;
  }
  char s[n + 1];
  memset(s, '0', sizeof(s));
  s[n] = '\0';
  if (n > 1) s[0] = '1';
  for (int i = 1; i < n + 1; ++i) {
    if (d[i] != -1) s[i - 1] = '0' + d[i];
  }
  cout << s << endl;
  return 0;
}
