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

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

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

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

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

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

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

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

m.t = d
m.w = a
a.u = d
a.x = k
n.q = a
b.t = n
b.w = k
k.u = d
k.x = a
j.t = n
j.w = a
d.q = k
i.t = d
i.w = k
c.t = d
c.w = a
assert j.w.x.u.txt == "d"