def readval(file, ty):
    """Reads a line from file with an item of type ty

    :param file: input stream, for example sys.stdin
    :param ty: a type, for example int
    :returns: an element of type ty
    """
    return ty(file.readline())