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

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

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

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

n = A("n")
c = B("c")
l = C("l")
m = D("m")
g = C("g")
b = B("b")

n.u = c
c.r = m
c.s = b
l.u = n
l.p = m
l.s = m
m.r = b
m.q = c
g.u = n
g.p = m
g.s = m
b.r = m
b.s = c
assert c.r.q.s.r.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.txt = txt

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

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

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

n = A("n")
c = B("c")
l = C("l")
m = D("m")
g = C("g")
b = B("b")

n.u = c
c.r = m
c.s = b
l.u = n
l.p = m
l.s = m
m.r = b
m.q = c
g.u = n
g.p = m
g.s = m
b.r = m
b.s = c
assert c.r.q.s.r.txt == "m"