#include <bits/stdc++.h>
using namespace std;
struct Point {
  long long x, y;
  Point(long long x, long long y) : x(x), y(y) {}
  Point() : x(0), y(0) {}
  Point operator+(Point v) { return Point(x + v.x, y + v.y); }
  Point operator-(Point v) { return Point(x - v.x, y - v.y); }
  bool operator==(const Point &v) const { return x == v.x && y == v.y; }
  bool operator<(const Point &p1) const { return x < p1.x && y < p1.y; }
};
ostream &operator<<(ostream &out, Point const &v) {
  out << "Point(" << v.x << ", " << v.y << ')';
  return out;
}
istream &operator>>(istream &in, Point &v) {
  long long x, y;
  in >> x;
  in >> y;
  v.x = x;
  v.y = y;
  return in;
}
class Vector2 {
 public:
  double x, y;
  Vector2(double x = 0, double y = 0) : x(x), y(y) {}
  Vector2 operator+(Vector2 v) { return Vector2(x + v.x, y + v.y); }
  Vector2 operator-(Vector2 v) { return Vector2(x - v.x, y - v.y); }
  Vector2 operator*(double k) { return Vector2(x * k, y * k); }
  Vector2 operator/(double k) { return Vector2(x / k, y / k); }
  double length() { return sqrt(norm()); }
  double norm() { return x * x + y * y; }
  double dot(Vector2 v) { return x * v.x + y * v.y; }
  double cross(Vector2 v) { return x * v.y - y * v.x; }
  bool operator<(const Vector2 &v) const {
    return x != v.x ? x < v.x : y < v.y;
  }
  bool operator==(const Vector2 &v) const {
    return fabs(x - v.x) < 0.0000000001 && fabs(y - v.y) < 0.0000000001;
  }
};
ostream &operator<<(ostream &out, Vector2 const &v) {
  out << "Vector2(" << v.x << ", " << v.y << ')';
  return out;
}
istream &operator>>(istream &in, Vector2 &v) {
  double x, y;
  in >> x;
  in >> y;
  v.x = x;
  v.y = y;
  return in;
}
long long N, M;
vector<long long> D(3, -1);
bool input() {
  cin >> N >> M;
  long long a, b;
  bool noneZero = false;
  for (long long n = 0; n < M; n++) {
    cin >> a >> b;
    a--;
    if (D.at(a) >= 0 && D.at(a) != b) {
      cout << "-1" << endl;
      return false;
    }
    if (b == 0 && !noneZero && a < N - 1) {
      cout << "-1" << endl;
      return false;
    }
    D.at(a) = b;
    noneZero |= b != 0;
  }
  return true;
}
void solve() {
  for (long long n = 0; n < N; n++) {
    long long d = D.at(n);
    if (d == -1) {
      if (n == 0)
        cout << '1';
      else
        cout << '0';
    } else
      cout << d;
  }
  cout << endl;
}
int main() {
  bool r = input();
  if (r) solve();
  return 0;
}
