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

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

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

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

c = A("c")
m = B("m")
b = C("b")
e = D("e")
d = A("d")

c.s = d
c.t = d
c.z = b
m.t = d
m.s = d
m.v = d
m.o = e
b.s = d
e.w = m
d.s = c
d.t = c
d.z = b
assert e.w.o.w.t.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: A = None
        self.z: C = None
        self.t: A = None
        self.txt = txt

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

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

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

c = A("c")
m = B("m")
b = C("b")
e = D("e")
d = A("d")

c.s = d
c.t = d
c.z = b
m.t = d
m.s = d
m.v = d
m.o = e
b.s = d
e.w = m
d.s = c
d.t = c
d.z = b
assert e.w.o.w.t.s.txt == "c"