python
Code

# Code
```python3 []
class Solution:
    def lastVisitedIntegers(self, nums: List[int], k = 0) -> List[int]:
        seen, ans = deque(), []
        for x in nums:
            if x > 0:
                k = 0
                seen.appendleft(x)
            else:
                k += 1
                ans.append(-1 if k > len(seen) else seen[k-1])
        return ans
```
['Python3']