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

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

j = A("j")
b = B("b")
a = B("a")
e = A("e")
d = B("d")
c = A("c")
h = B("h")

j.x = c
j.u = c
b.y = j
b.z = e
a.y = e
a.z = c
e.x = c
e.u = j
d.y = j
d.z = j
c.x = e
c.u = j
h.y = j
h.z = j
assert h.y.x.x.u.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.u: A = None
        self.txt = txt

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

j = A("j")
b = B("b")
a = B("a")
e = A("e")
d = B("d")
c = A("c")
h = B("h")

j.x = c
j.u = c
b.y = j
b.z = e
a.y = e
a.z = c
e.x = c
e.u = j
d.y = j
d.z = j
c.x = e
c.u = j
h.y = j
h.z = j
assert h.y.x.x.u.x.txt == "c"