class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.y: C = None
        self.u: A = None
        self.p: D = None
        self.txt = txt

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

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

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

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

h.q = l
h.y = e
h.u = d
h.p = k
l.p = k
l.w = e
e.q = n
k.x = e
d.q = f
d.y = e
d.u = h
d.p = k
f.p = k
f.w = m
n.q = m
m.q = n
assert k.x.q.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.y: C = None
        self.u: A = None
        self.p: D = None
        self.txt = txt

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

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

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

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

h.q = l
h.y = e
h.u = d
h.p = k
l.p = k
l.w = e
e.q = n
k.x = e
d.q = f
d.y = e
d.u = h
d.p = k
f.p = k
f.w = m
n.q = m
m.q = n
assert k.x.q.q.q.txt == "n"