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

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

g = A("g")
e = B("e")
d = A("d")
b = A("b")
f = B("f")
m = A("m")
a = B("a")

g.z = m
g.t = m
e.v = a
e.o = a
d.z = g
d.t = m
b.z = m
b.t = d
f.v = a
f.o = e
m.z = b
m.t = b
a.v = e
a.o = e
assert a.o.v.o.v.v.o.txt == "
class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.t: A = None
        self.txt = txt

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

g = A("g")
e = B("e")
d = A("d")
b = A("b")
f = B("f")
m = A("m")
a = B("a")

g.z = m
g.t = m
e.v = a
e.o = a
d.z = g
d.t = m
b.z = m
b.t = d
f.v = a
f.o = e
m.z = b
m.t = b
a.v = e
a.o = e
assert a.o.v.o.v.v.o.txt == "a"