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

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

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

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

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

m.y = n
m.t = d
d.s = m
d.w = m
d.o = m
d.q = f
n.w = f
f.o = m
f.t = d
assert f.t.q.o.t.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.t: B = None
        self.txt = txt

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

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

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

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

m.y = n
m.t = d
d.s = m
d.w = m
d.o = m
d.q = f
n.w = f
f.o = m
f.t = d
assert f.t.q.o.t.txt == "d"