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

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

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

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

m = A("m")
i = B("i")
j = C("j")
a = D("a")

m.o = i
m.y = i
m.t = a
i.t = m
i.o = j
j.p = a
a.w = j
a.t = j
assert j.p.w.p.t.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.y: B = None
        self.t: D = None
        self.txt = txt

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

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

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

m = A("m")
i = B("i")
j = C("j")
a = D("a")

m.o = i
m.y = i
m.t = a
i.t = m
i.o = j
j.p = a
a.w = j
a.t = j
assert j.p.w.p.t.txt == "j"