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

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

class C:
    def __init__(self, txt: str):
        self.s: C = None
        self.y: A = None
        self.txt = txt

l = A("l")
d = B("d")
c = C("c")
j = B("j")
h = A("h")
a = C("a")

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

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

class C:
    def __init__(self, txt: str):
        self.s: C = None
        self.y: A = None
        self.txt = txt

l = A("l")
d = B("d")
c = C("c")
j = B("j")
h = A("h")
a = C("a")

l.z = h
d.t = a
d.u = a
c.s = a
c.y = h
j.t = a
j.u = c
h.z = l
a.s = c
a.y = l
assert j.u.s.y.z.z.z.txt == "h"