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

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

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

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

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

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

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

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

g.q = c
d.s = c
a.s = k
a.y = m
a.u = m
k.s = c
k.y = m
k.u = m
n.q = c
c.s = k
c.y = m
c.u = d
m.s = k
assert n.q.y.s.s.txt == "c"