class RingRange {

  public static RingRange merge(List<RingRange> ranges) {
    // sor
    Collections.sort(ranges, START_COMPARATOR);

    // find gap
    int gap = 0;
    for (; gap < ranges.size() - 1; gap++) {
      RingRange left = ranges.get(gap);
      RingRange right = ranges.get(gap + 1);
      if (!left.end.equals(right.start)) {
        break;
      }
    }

    // return merged
    if (gap == ranges.size() - 1) {
      return new RingRange(ranges.get(0).start, ranges.get(gap).end);
    } else {
      return new RingRange(ranges.get(gap + 1).start, ranges.get(gap).end);
    }
  }

  public  RingRange(BigInteger start, BigInteger end);
  public  RingRange(String... range);

}