#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
const int MOD = 1000000007;
const int INF = INT_MAX;
const long long int LLINF = 1LL << 60;
int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<char> ans(n);
  char c;
  int s;
  vector<bool> cor(n);
  for (int i = 0; i < (m); ++i) {
    cin >> s >> c;
    if (cor[s - 1] && ans[s - 1] != c) {
      cout << (-1) << endl;
      return 0;
    }
    if (s == 1 && c == '0') {
      cout << (-1) << endl;
      return 0;
    }
    ans[s - 1] = c;
    cor[s - 1] = true;
  }
  for (int i = 0; i < (n); ++i) {
    if (cor[i]) continue;
    if (i == 0 && n != 1)
      ans[i] = '1';
    else
      ans[i] = '0';
  }
  for (int i = 0; i < (n); ++i) printf("%c", ans[i]);
  return 0;
}
