#!/usr/bin/env ruby #require 'debug' require 'set' class FindString def initialize t=gets.to_i #Num of test cases @string_store=Array.new @query_store=Array.new #@hash_store=Hash.new @set_store=Set.new #Push all the Strings in Array 1.upto(t) do @string_store.push(gets) end query=gets.to_i #Query indexes Array 1.upto(query) do @query_store.push(gets.to_i) end calc_index #Calculate the index in final resulted array of union of substring end def calc_index =begin for string in @string_store do for c in 0...string.length index_to_sum=0 while c+index_to_sum