Lines

Given l lines of numbers displayed horizontally, having n words in common, let’s consider these numbers as portals allowing us to switch lists. Find the maximal sum that it’s possible to make. It’s only possible to mobve forward or change lines if th enulber allows it.

Input

N cases

  • 100 ≤ N ≤ 500
  • 2 ≤ l ≤ 10
  • 5 ≤ n ≤ 10

Examples

I/O SU

Évènement organisé par ALIAS