class Buffer {

    char charAt(int pos) {
        int seg = pos / segmentLen;
        int off = pos % segmentLen;

        int index = begins[seg] + off;
        return buf.charAt(index);
    }

}

class BufferTest {

    static String lng;

    @Test public void firstFailure() {

        long seed = 1394639167285L;
        
        Buffer b = new Buffer(lng, 3, seed);

        StringBuilder recover = new StringBuilder();
        for (int i = 0; i < lng.length(); i++) {
            recover.append(b.charAt(i));
        }
        
        assertEquals(recover.toString(), lng);
    }

}