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

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

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

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

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

f = A("f")
c = B("c")
m = C("m")
d = D("d")
g = E("g")

f.v = d
f.z = d
f.x = c
c.p = d
c.w = g
m.t = f
d.w = g
d.q = c
g.z = m
assert c.w.z.t.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: D = None
        self.z: D = None
        self.x: B = None
        self.txt = txt

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

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

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

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

f = A("f")
c = B("c")
m = C("m")
d = D("d")
g = E("g")

f.v = d
f.z = d
f.x = c
c.p = d
c.w = g
m.t = f
d.w = g
d.q = c
g.z = m
assert c.w.z.t.v.txt == "d"