Matrix queries

Company: Google_25oct

Difficulty: medium