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

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

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

d = A("d")
n = B("n")
i = C("i")
h = C("h")
f = B("f")
c = C("c")
e = C("e")
m = A("m")

d.u = f
d.o = m
n.y = c
i.u = f
h.u = f
f.y = i
c.u = n
e.u = f
m.u = f
m.o = d
assert h.u.y.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.o: A = None
        self.txt = txt

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

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

d = A("d")
n = B("n")
i = C("i")
h = C("h")
f = B("f")
c = C("c")
e = C("e")
m = A("m")

d.u = f
d.o = m
n.y = c
i.u = f
h.u = f
f.y = i
c.u = n
e.u = f
m.u = f
m.o = d
assert h.u.y.u.txt == "f"