```
class Vector2D(object):
def __init__(self, vec2d):
"""
Initialize your data structure here.
:type vec2d: List[List[int]]
"""
self.vec2d = [x for x in vec2d if x]
def next(self):
"""
:rtype: int
"""
if isinstance(self.vec2d[0], list):
self.vec2d = self.vec2d[0] + self.vec2d[1:]
return self.vec2d.pop(0)
def hasNext(self):
"""
:rtype: bool
"""
return len(self.vec2d) > 0
```