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

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

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

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

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

k.y = c
k.w = c
f.q = m
c.u = f
c.r = f
c.q = k
c.x = h
n.y = f
n.p = f
n.s = c
n.z = h
h.y = f
h.p = f
h.s = c
h.z = m
m.y = f
m.p = f
m.s = c
m.z = n
assert c.q.y.q.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.w: C = None
        self.txt = txt

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

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

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

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

k.y = c
k.w = c
f.q = m
c.u = f
c.r = f
c.q = k
c.x = h
n.y = f
n.p = f
n.s = c
n.z = h
h.y = f
h.p = f
h.s = c
h.z = m
m.y = f
m.p = f
m.s = c
m.z = n
assert c.q.y.q.txt == "k"