class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.v: B = None
        self.z: E = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.x: B = None
        self.s: A = None
        self.r: E = None
        self.w: A = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.p: F = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.z: C = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.r: C = None
        self.txt = txt

n = A("n")
d = B("d")
a = C("a")
l = D("l")
c = E("c")
m = F("m")
k = A("k")

n.y = d
n.v = d
n.z = c
d.p = l
d.s = a
a.x = d
a.s = k
a.r = c
a.w = n
l.p = m
c.z = a
m.r = a
k.y = d
k.v = d
k.z = c
assert c.z.x.s.x.s.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.v: B = None
        self.z: E = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.x: B = None
        self.s: A = None
        self.r: E = None
        self.w: A = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.p: F = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.z: C = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.r: C = None
        self.txt = txt

n = A("n")
d = B("d")
a = C("a")
l = D("l")
c = E("c")
m = F("m")
k = A("k")

n.y = d
n.v = d
n.z = c
d.p = l
d.s = a
a.x = d
a.s = k
a.r = c
a.w = n
l.p = m
c.z = a
m.r = a
k.y = d
k.v = d
k.z = c
assert c.z.x.s.x.s.txt == "a"