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

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

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

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

e = A("e")
h = B("h")
g = C("g")
n = D("n")
k = C("k")
l = C("l")

e.p = h
h.r = e
h.s = e
h.q = k
g.z = h
n.w = h
n.s = g
n.t = e
k.z = h
l.z = h
assert n.s.z.q.z.q.z.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.txt = txt

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

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

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

e = A("e")
h = B("h")
g = C("g")
n = D("n")
k = C("k")
l = C("l")

e.p = h
h.r = e
h.s = e
h.q = k
g.z = h
n.w = h
n.s = g
n.t = e
k.z = h
l.z = h
assert n.s.z.q.z.q.z.txt == "h"