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

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

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

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

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

m.o = n
l.u = m
l.s = f
n.u = h
n.w = c
c.w = m
c.q = l
f.w = m
f.q = l
h.u = b
h.w = f
j.o = b
b.u = n
b.w = f
assert m.o.u.u.u.u.w.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.txt = txt

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

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

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

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

m.o = n
l.u = m
l.s = f
n.u = h
n.w = c
c.w = m
c.q = l
f.w = m
f.q = l
h.u = b
h.w = f
j.o = b
b.u = n
b.w = f
assert m.o.u.u.u.u.w.txt == "f"