#!/usr/bin/env python
##
# Takes a list of keys to extract from the config file and just passes those on.
# This expects the input to be key value pairs (having a header of kv) and passes on a kv pair
import sys

# Ensure we are dealing with kv pairs
if sys.stdin.readline().strip() != 'kv':
    raise Exception('Header needs to be kv')

# Write our header out
sys.stdout.write('kv\n')

keys = set(sys.argv[1:])

# Loop through all of the input, if a key is in keys, print it
for line in sys.stdin:
    k, v = line.split('=', 1)
    if k in keys:
        sys.stdout.write(line)
        
