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

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

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

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

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

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

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

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

b.q = k
b.s = c
a.t = m
a.y = d
a.u = k
k.x = m
k.w = a
k.r = c
n.x = k
n.w = d
n.r = b
m.x = k
m.w = a
m.r = c
d.t = k
d.y = a
d.u = n
c.q = m
c.s = b
assert d.u.x.w.txt == "a"