```
# Initialize your data structure here.
# @param {integer[][]} vec2d
def __init__(self, vec2d):
# Convert 2d vector to 1d vector first can avoid
# the different range issues
# self.ls = reduce(lambda x, y: x+y, vec2d, [])
# self.ls = sum(vec2d, [])
self.ls = [x for row in vec2d for x in row]
self.i = 0
# @return {integer}
def next(self):
tmp = self.i
self.i += 1
return self.ls[tmp]
# @return {boolean}
def hasNext(self):
return self.i < len(self.ls)
```