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

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

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

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

e = A("e")
a = B("a")
d = C("d")
m = D("m")
i = C("i")

e.r = d
e.v = d
e.y = m
a.y = m
d.w = a
m.z = a
m.w = a
m.q = i
m.o = e
i.w = a
assert a.y.o.y.w.y.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.y: D = None
        self.v: C = None
        self.txt = txt

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

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

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

e = A("e")
a = B("a")
d = C("d")
m = D("m")
i = C("i")

e.r = d
e.v = d
e.y = m
a.y = m
d.w = a
m.z = a
m.w = a
m.q = i
m.o = e
i.w = a
assert a.y.o.y.w.y.txt == "m"