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

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

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

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

c = A("c")
k = B("k")
l = C("l")
n = D("n")
g = A("g")
j = D("j")

c.z = n
k.x = j
l.y = k
l.z = g
l.x = g
l.w = n
n.v = g
n.y = g
n.p = l
n.t = l
g.z = n
j.v = c
j.y = g
j.p = l
j.t = l
assert n.v.z.v.z.t.x.txt == "
class A:
    def __init__(self, txt: str):
        self.z: D = None
        self.txt = txt

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

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

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

c = A("c")
k = B("k")
l = C("l")
n = D("n")
g = A("g")
j = D("j")

c.z = n
k.x = j
l.y = k
l.z = g
l.x = g
l.w = n
n.v = g
n.y = g
n.p = l
n.t = l
g.z = n
j.v = c
j.y = g
j.p = l
j.t = l
assert n.v.z.v.z.t.x.txt == "g"