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

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

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

k = A("k")
d = B("d")
a = C("a")
c = B("c")
m = C("m")
n = A("n")
e = C("e")
b = A("b")

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

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

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

k = A("k")
d = B("d")
a = C("a")
c = B("c")
m = C("m")
n = A("n")
e = C("e")
b = A("b")

k.x = e
k.q = d
d.r = c
d.s = c
a.u = c
a.p = b
c.r = d
c.s = d
m.u = c
m.p = n
n.x = e
n.q = d
e.u = d
e.p = k
b.x = e
b.q = d
assert b.q.r.s.r.txt == "c"