Spoj glass beads

Can anyone explain me how to do this problem using suffix array?
Please.