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

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

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

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

c.u = b
a.y = b
j.z = b
b.y = h
i.y = a
f.u = b
n.u = a
m.z = b
h.y = b
assert c.u.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.txt = txt

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

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

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

c.u = b
a.y = b
j.z = b
b.y = h
i.y = a
f.u = b
n.u = a
m.z = b
h.y = b
assert c.u.y.y.txt == "b"