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

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

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

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

l.s = k
l.w = m
k.q = i
k.y = i
k.r = l
d.u = g
d.x = l
i.s = k
i.w = k
g.u = n
g.x = l
j.u = g
j.x = a
c.q = i
c.r = i
c.y = i
m.q = i
m.r = l
m.y = l
a.s = m
a.w = c
n.u = g
n.x = l
assert j.x.s.q.s.q.w.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.w: B = None
        self.txt = txt

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

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

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

l.s = k
l.w = m
k.q = i
k.y = i
k.r = l
d.u = g
d.x = l
i.s = k
i.w = k
g.u = n
g.x = l
j.u = g
j.x = a
c.q = i
c.r = i
c.y = i
m.q = i
m.r = l
m.y = l
a.s = m
a.w = c
n.u = g
n.x = l
assert j.x.s.q.s.q.w.txt == "k"