class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.q: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.z: B = None
        self.txt = txt

i = A("i")
n = B("n")
g = B("g")
j = A("j")
d = B("d")
e = B("e")
b = A("b")
h = B("h")

i.v = g
i.q = e
n.z = e
g.z = h
j.v = d
j.q = d
d.z = h
e.z = g
b.v = d
b.q = e
h.z = n
assert g.z.z.z.z.z.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.q: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.z: B = None
        self.txt = txt

i = A("i")
n = B("n")
g = B("g")
j = A("j")
d = B("d")
e = B("e")
b = A("b")
h = B("h")

i.v = g
i.q = e
n.z = e
g.z = h
j.v = d
j.q = d
d.z = h
e.z = g
b.v = d
b.q = e
h.z = n
assert g.z.z.z.z.z.z.z.txt == "e"