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

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

i = A("i")
d = B("d")
c = B("c")
k = A("k")
g = A("g")
e = A("e")

i.x = e
i.z = k
d.q = g
d.v = c
c.q = g
c.v = d
k.x = g
k.z = g
g.x = i
g.z = i
e.x = k
e.z = i
assert i.x.z.z.z.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.z: A = None
        self.txt = txt

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

i = A("i")
d = B("d")
c = B("c")
k = A("k")
g = A("g")
e = A("e")

i.x = e
i.z = k
d.q = g
d.v = c
c.q = g
c.v = d
k.x = g
k.z = g
g.x = i
g.z = i
e.x = k
e.z = i
assert i.x.z.z.z.x.x.txt == "e"