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

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

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

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

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

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

d.z = g
d.o = c
k.q = d
c.z = h
c.w = k
c.t = g
h.v = c
h.w = g
m.z = g
g.v = c
g.w = h
assert c.t.v.w.txt == "
class A:
    def __init__(self, txt: str):
        self.z: D = None
        self.o: C = None
        self.txt = txt

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

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

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

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

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

d.z = g
d.o = c
k.q = d
c.z = h
c.w = k
c.t = g
h.v = c
h.w = g
m.z = g
g.v = c
g.w = h
assert c.t.v.w.txt == "k"