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

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

d = A("d")
a = B("a")
b = A("b")
g = A("g")
i = B("i")
k = B("k")
f = B("f")

d.o = b
d.z = k
a.x = i
a.v = g
b.o = d
b.z = k
g.o = b
g.z = f
i.x = f
i.v = d
k.x = a
k.v = d
f.x = a
f.v = d
assert a.x.x.v.z.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.z: B = None
        self.txt = txt

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

d = A("d")
a = B("a")
b = A("b")
g = A("g")
i = B("i")
k = B("k")
f = B("f")

d.o = b
d.z = k
a.x = i
a.v = g
b.o = d
b.z = k
g.o = b
g.z = f
i.x = f
i.v = d
k.x = a
k.v = d
f.x = a
f.v = d
assert a.x.x.v.z.txt == "k"