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

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

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

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

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

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

m.w = h
k.v = f
k.w = m
h.x = g
h.q = m
h.w = k
g.t = f
f.q = h
assert f.q.w.w.w.q.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.txt = txt

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

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

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

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

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

m.w = h
k.v = f
k.w = m
h.x = g
h.q = m
h.w = k
g.t = f
f.q = h
assert f.q.w.w.w.q.txt == "m"