# The read4 API is already defined for you.# def read4(buf4: List[str]) -> int:classSolution:def__init__(self): self.queue = collections.deque()defread(self,buf,n): i =0while i < n: buf4 = [''] *4 _ =read4(buf4) self.queue.extend(buf4) count =min(len(self.queue), n - i)ifnot count:break buf[i:]= [self.queue.popleft()for _ inrange(count)] i += countreturn i