There is series of 20 numbers composed by two numbers is given like 9876,7698,7676,9898,987698,769876

Develop a logic in java to find out these two numbers series composed by

First number is - 98 Second is-76

How to develop a logic

Another series - 1213,121312,1313,1212,12131213 First Number-12 Second Number-13