#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
template <class T>
ostream& operator<<(ostream& os, vector<T> V) {
  os << "[ ";
  for (auto v : V) os << v << " ";
  return os << "]";
}
template <class L, class R>
ostream& operator<<(ostream& os, pair<L, R> P) {
  return os << "(" << P.first << "," << P.second << ")";
}
template <typename T, typename U>
pair<T, U> operator+(const pair<T, U>& l, const std::pair<T, U>& r) {
  return {l.first + r.first, l.second + r.second};
}
const long long int mod = 1e9 + 7;
const long long int MAX_NODES = 200001;
const long long int MAX_LOG = 50;
const long long int maxn = 400000 + 10;
long long int power(long long int x, long long int n) {
  long long int res = 1;
  for (; n > 0; n >>= 1) {
    if (n & 1) res = (res * x) % mod;
    x = (x * x) % mod;
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m;
  cin >> n >> m;
  string ans(n, '?');
  bool check = 1;
  int s[m], c[m];
  for (int i = 0; i < m; i++) {
    cin >> s[i] >> c[i];
    s[i]--;
    if (ans[s[i]] == '?') {
      ans[s[i]] = c[i] + '0';
    } else {
      check &= (ans[s[i]] == c[i] + '0');
    }
  }
  if (!check) {
    cout << "-1" << '\n';
  } else {
    if (ans[0] == '0' && n > 1) {
      cout << -1 << '\n';
      return 0;
    }
    for (long long int i = 0; i < n; i++) {
      if (ans[i] == '?') ans[i] = '1';
      cout << ans[i];
    }
  }
}
