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

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

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

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

c = A("c")
k = B("k")
d = C("d")
b = D("b")
e = A("e")
h = C("h")
l = A("l")

c.w = l
k.t = d
k.p = b
d.u = h
d.z = k
d.r = b
d.w = c
b.z = e
b.q = h
e.w = c
h.u = d
h.z = k
h.r = b
h.w = l
l.w = e
assert h.u.z.p.q.z.p.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.txt = txt

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

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

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

c = A("c")
k = B("k")
d = C("d")
b = D("b")
e = A("e")
h = C("h")
l = A("l")

c.w = l
k.t = d
k.p = b
d.u = h
d.z = k
d.r = b
d.w = c
b.z = e
b.q = h
e.w = c
h.u = d
h.z = k
h.r = b
h.w = l
l.w = e
assert h.u.z.p.q.z.p.txt == "b"