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

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

class C:
    def __init__(self, txt: str):
        self.p: A = None
        self.x: A = None
        self.v: F = None
        self.txt = txt

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

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

class F:
    def __init__(self, txt: str):
        self.v: E = None
        self.t: B = None
        self.txt = txt

e = A("e")
f = B("f")
g = C("g")
n = D("n")
c = E("c")
k = F("k")
a = B("a")

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

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

class C:
    def __init__(self, txt: str):
        self.p: A = None
        self.x: A = None
        self.v: F = None
        self.txt = txt

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

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

class F:
    def __init__(self, txt: str):
        self.v: E = None
        self.t: B = None
        self.txt = txt

e = A("e")
f = B("f")
g = C("g")
n = D("n")
c = E("c")
k = F("k")
a = B("a")

e.z = n
f.z = k
f.y = e
f.p = n
f.w = n
f.x = c
g.p = e
g.x = e
g.v = k
n.y = f
n.x = g
c.r = g
k.v = c
k.t = a
a.z = k
a.y = e
a.p = n
a.w = n
a.x = c
assert c.r.p.z.y.w.x.txt == "g"