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

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

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

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

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

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

i.x = g
i.z = l
f.y = a
d.x = a
d.z = i
c.x = f
c.z = l
h.y = g
k.x = a
k.z = c
l.x = h
l.z = b
a.y = h
b.x = h
b.z = i
g.y = f
assert g.y.y.y.txt == "h"