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

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

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

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

class E:
    def __init__(self, txt: str):
        self.v: B = None
        self.txt = txt

b = A("b")
m = B("m")
c = C("c")
a = D("a")
n = E("n")

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

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

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

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

class E:
    def __init__(self, txt: str):
        self.v: B = None
        self.txt = txt

b = A("b")
m = B("m")
c = C("c")
a = D("a")
n = E("n")

b.s = c
m.q = c
c.p = m
a.r = m
a.q = n
a.u = n
n.v = m
assert c.p.q.p.txt == "m"