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

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

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

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

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

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

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

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

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

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

k.z = d
k.q = d
d.p = i
d.q = l
d.w = l
d.s = m
j.x = f
j.w = h
i.y = h
i.x = h
f.x = j
f.w = h
h.y = i
h.x = i
l.p = h
l.q = d
l.w = d
l.s = k
m.z = d
m.q = l
assert k.q.p.x.x.y.x.x.txt == "h"