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

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

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

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

c = A("c")
n = B("n")
m = C("m")
h = D("h")
l = B("l")

c.s = h
c.q = h
c.w = n
c.r = l
n.v = h
n.w = h
n.s = c
m.q = c
m.p = n
h.z = l
h.s = m
h.t = c
h.w = n
l.v = h
l.w = h
l.s = c
assert c.s.t.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.s: D = None
        self.q: D = None
        self.w: B = None
        self.r: B = None
        self.txt = txt

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

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

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

c = A("c")
n = B("n")
m = C("m")
h = D("h")
l = B("l")

c.s = h
c.q = h
c.w = n
c.r = l
n.v = h
n.w = h
n.s = c
m.q = c
m.p = n
h.z = l
h.s = m
h.t = c
h.w = n
l.v = h
l.w = h
l.s = c
assert c.s.t.w.w.txt == "h"