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

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

c = A("c")
l = B("l")
j = B("j")
a = B("a")
g = B("g")
f = B("f")
h = A("h")
i = A("i")
d = A("d")
e = B("e")

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

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

c = A("c")
l = B("l")
j = B("j")
a = B("a")
g = B("g")
f = B("f")
h = A("h")
i = A("i")
d = A("d")
e = B("e")

c.z = i
c.x = j
l.u = f
j.u = g
a.u = j
g.u = j
f.u = a
h.z = c
h.x = e
i.z = d
i.x = l
d.z = c
d.x = j
e.u = a
assert i.z.x.u.u.u.u.u.u.u.txt == "g"