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

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

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

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

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

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

m.v = l
g.z = l
d.q = m
d.s = n
n.w = d
n.z = f
l.o = n
l.v = m
l.r = g
f.z = l
assert d.s.w.s.w.txt == "
class A:
    def __init__(self, txt: str):
        self.v: E = None
        self.txt = txt

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

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

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

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

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

m.v = l
g.z = l
d.q = m
d.s = n
n.w = d
n.z = f
l.o = n
l.v = m
l.r = g
f.z = l
assert d.s.w.s.w.txt == "d"