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

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

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

d = A("d")
j = B("j")
f = C("f")
i = C("i")
a = C("a")
c = C("c")
h = B("h")
n = A("n")

d.y = h
d.z = i
j.w = h
j.s = h
j.o = n
f.u = n
i.u = d
a.u = d
c.u = n
h.w = j
h.s = j
h.o = n
n.y = j
n.z = a
assert c.u.z.u.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.z: C = None
        self.txt = txt

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

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

d = A("d")
j = B("j")
f = C("f")
i = C("i")
a = C("a")
c = C("c")
h = B("h")
n = A("n")

d.y = h
d.z = i
j.w = h
j.s = h
j.o = n
f.u = n
i.u = d
a.u = d
c.u = n
h.w = j
h.s = j
h.o = n
n.y = j
n.z = a
assert c.u.z.u.y.txt == "h"