14705 - Prez's puns   

Description

Symboli Rudof is trying to find new jokes to tell Air Groove, and she's asking you to inspire her! In order to do that, she's given you a list of sentences.
 

Your mission is to write a function called "pun" that takes in a list of string and a list of queries and print out the words at the specified index of each sentences to see if it inspires her.

Seeing you so excited to help her, she's also given you a piece of code so you can focus on your main task:

def pun(sentences: list, queries: list)->None:
    #Write your code here


(line, query) = map(int, input().split())
sentences = []
queries = []
for i in range(line):
    sentences.append(input())
for i in range(query):
    queries.append(tuple(map(int, input().split())))
pun(sentences, queries)

Input

The function will takes in 2 parameters:

  • The first parameter is a list of strings
  • The second parameter is a list of tuples (a, b):
    • The first item a is the line Symboli Rudolf wants you to start from
    • The second item b is the index of the word.

>= 0, b >= 0

Output

For each tuple (ab), print out the word at index b from sentence a to the last sentence of the list.

If the number of word in the current sentence is less than or equal to b, print out the last word of the sentence. 
Print out an empty line if a is larger than the number of sentences.

Sample Input  Download

Sample Output  Download

Tags




Discuss