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

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

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

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

g = A("g")
d = B("d")
m = C("m")
a = D("a")
f = A("f")
k = D("k")
j = A("j")
n = C("n")
e = B("e")
i = A("i")

g.w = a
g.q = j
d.r = k
d.u = f
d.t = n
m.s = n
m.q = n
a.r = e
f.w = k
f.q = i
k.r = e
j.w = k
j.q = f
n.s = m
n.q = m
e.r = k
e.u = i
e.t = n
i.w = a
i.q = j
assert a.r.t.s.txt == "
class A:
    def __init__(self, txt: str):
        self.w: D = None
        self.q: A = None
        self.txt = txt

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

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

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

g = A("g")
d = B("d")
m = C("m")
a = D("a")
f = A("f")
k = D("k")
j = A("j")
n = C("n")
e = B("e")
i = A("i")

g.w = a
g.q = j
d.r = k
d.u = f
d.t = n
m.s = n
m.q = n
a.r = e
f.w = k
f.q = i
k.r = e
j.w = k
j.q = f
n.s = m
n.q = m
e.r = k
e.u = i
e.t = n
i.w = a
i.q = j
assert a.r.t.s.txt == "m"