#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
const int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 62) - 1;
ll ceil(const ll a, const ll b) { return ((a) + (b)-1) / b; }
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, m;
  cin >> n >> m;
  vi ans(n, -1);
  for (int i = 0; i < m; i++) {
    int s, c;
    cin >> s >> c;
    s--;
    bool ok = true;
    if (ans[s] != -1 && ans[s] != c) ok = false;
    if (s == 0 && c == 0 && n != 1) ok = false;
    if (!ok) {
      cout << -1 << "\n";
      return 0;
    }
    ans[s] = c;
  }
  for (int i = 0; i < n; i++) {
    if (ans[i] == -1 && i == 0 && n != 1)
      cout << 1;
    else if (ans[i] == -1 && i != 0)
      cout << 0;
    else
      cout << ans[i];
  }
}
