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

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

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

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

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

m.s = l
m.u = l
m.o = c
m.r = h
f.p = m
j.q = m
j.v = b
j.y = b
l.u = m
n.u = m
c.p = m
a.u = m
b.q = m
b.v = j
b.y = j
h.p = m
assert f.p.r.p.r.p.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.s: D = None
        self.o: B = None
        self.r: B = None
        self.u: D = None
        self.txt = txt

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

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

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

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

m.s = l
m.u = l
m.o = c
m.r = h
f.p = m
j.q = m
j.v = b
j.y = b
l.u = m
n.u = m
c.p = m
a.u = m
b.q = m
b.v = j
b.y = j
h.p = m
assert f.p.r.p.r.p.u.u.txt == "m"