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

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

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

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

h = A("h")
e = B("e")
l = C("l")
j = D("j")
k = A("k")
i = B("i")
m = C("m")
f = B("f")
d = D("d")

h.w = k
e.z = d
l.x = k
l.t = h
j.q = m
k.w = h
i.z = d
m.x = h
m.t = h
f.z = j
d.q = m
assert d.q.x.w.w.w.w.w.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.txt = txt

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

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

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

h = A("h")
e = B("e")
l = C("l")
j = D("j")
k = A("k")
i = B("i")
m = C("m")
f = B("f")
d = D("d")

h.w = k
e.z = d
l.x = k
l.t = h
j.q = m
k.w = h
i.z = d
m.x = h
m.t = h
f.z = j
d.q = m
assert d.q.x.w.w.w.w.w.w.w.txt == "k"