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

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

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

class D:
    def __init__(self, txt: str):
        self.y: C = None
        self.txt = txt

i = A("i")
d = B("d")
n = C("n")
k = D("k")
a = A("a")
m = C("m")
j = A("j")
h = C("h")

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

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

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

class D:
    def __init__(self, txt: str):
        self.y: C = None
        self.txt = txt

i = A("i")
d = B("d")
n = C("n")
k = D("k")
a = A("a")
m = C("m")
j = A("j")
h = C("h")

i.q = k
i.t = d
d.r = k
d.u = n
n.x = a
n.y = k
n.w = k
k.y = n
a.q = k
a.t = d
m.x = i
m.y = k
m.w = k
j.q = k
j.t = d
h.x = i
h.y = k
h.w = k
assert a.q.y.x.t.u.txt == "n"