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

class B:
    def __init__(self, txt: str):
        self.o: B = None
        self.w: D = None
        self.txt = txt

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

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

a = A("a")
k = B("k")
j = C("j")
i = D("i")
c = C("c")
n = D("n")
e = B("e")
m = A("m")

a.s = e
a.u = e
a.q = c
k.o = e
k.w = i
j.q = c
j.s = e
i.r = c
i.u = e
c.q = j
c.s = k
n.r = c
n.u = k
e.o = k
e.w = i
m.s = e
m.q = c
m.u = k
assert a.q.q.s.o.w.r.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.q: C = None
        self.u: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.o: B = None
        self.w: D = None
        self.txt = txt

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

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

a = A("a")
k = B("k")
j = C("j")
i = D("i")
c = C("c")
n = D("n")
e = B("e")
m = A("m")

a.s = e
a.u = e
a.q = c
k.o = e
k.w = i
j.q = c
j.s = e
i.r = c
i.u = e
c.q = j
c.s = k
n.r = c
n.u = k
e.o = k
e.w = i
m.s = e
m.q = c
m.u = k
assert a.q.q.s.o.w.r.txt == "c"