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

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

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

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

class E:
    def __init__(self, txt: str):
        self.v: F = None
        self.x: A = None
        self.p: B = None
        self.z: B = None
        self.r: F = None
        self.q: C = None
        self.txt = txt

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

m = A("m")
k = B("k")
i = C("i")
e = D("e")
f = E("f")
c = F("c")

m.r = k
k.y = f
k.z = f
k.v = e
k.w = i
i.z = f
e.z = k
e.r = m
f.v = c
f.r = c
f.x = m
f.p = k
f.z = k
f.q = i
c.q = k
assert c.q.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.v: F = None
        self.x: A = None
        self.p: B = None
        self.z: B = None
        self.r: F = None
        self.q: C = None
        self.txt = txt

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

m = A("m")
k = B("k")
i = C("i")
e = D("e")
f = E("f")
c = F("c")

m.r = k
k.y = f
k.z = f
k.v = e
k.w = i
i.z = f
e.z = k
e.r = m
f.v = c
f.r = c
f.x = m
f.p = k
f.z = k
f.q = i
c.q = k
assert c.q.z.z.txt == "k"