#
# lru design
# @param operators int整型二维数组 the ops
# @param k int整型 the k
# @return int整型一维数组
#
import collections

class Solution:
    def LRU(self , operators , k ):
        # write code here
        new_lis = []
        dic = collections.OrderedDict() # 有序字典
        for operator in operators:
            if operator[0] == 1:
                dic[operator[1]] = operator[2]
                dic.move_to_end(operator[1])
                if len(dic.items()) > k:
                    dic.popitem(0)
            elif operator[0] == 2:
                res = dic.get(operator[1],-1)
                if res != -1:
                    dic.move_to_end(operator[1])
                new_lis.append(res)
        return new_lis