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

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

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

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

k = A("k")
l = B("l")
m = C("m")
g = D("g")
j = C("j")
d = A("d")

k.z = g
k.w = l
l.p = m
l.w = m
l.t = m
l.y = d
m.q = l
m.r = l
m.s = g
g.p = k
g.v = d
g.w = l
j.q = l
j.r = l
j.s = g
d.z = g
d.w = l
assert k.z.w.w.q.y.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: D = None
        self.w: B = None
        self.txt = txt

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

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

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

k = A("k")
l = B("l")
m = C("m")
g = D("g")
j = C("j")
d = A("d")

k.z = g
k.w = l
l.p = m
l.w = m
l.t = m
l.y = d
m.q = l
m.r = l
m.s = g
g.p = k
g.v = d
g.w = l
j.q = l
j.r = l
j.s = g
d.z = g
d.w = l
assert k.z.w.w.q.y.z.txt == "g"