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

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

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

c = A("c")
b = B("b")
h = C("h")
f = B("f")
n = C("n")
l = A("l")
j = C("j")
d = B("d")

c.o = f
c.p = l
c.w = l
b.u = c
h.y = j
f.u = c
n.y = h
l.o = f
l.p = c
l.w = c
j.y = h
d.u = l
assert h.y.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.p: A = None
        self.w: A = None
        self.txt = txt

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

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

c = A("c")
b = B("b")
h = C("h")
f = B("f")
n = C("n")
l = A("l")
j = C("j")
d = B("d")

c.o = f
c.p = l
c.w = l
b.u = c
h.y = j
f.u = c
n.y = h
l.o = f
l.p = c
l.w = c
j.y = h
d.u = l
assert h.y.y.y.y.txt == "h"