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

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

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

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

e = A("e")
b = B("b")
j = C("j")
m = D("m")

e.t = m
b.t = m
j.o = b
j.p = m
m.o = j
m.y = b
assert e.t.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.t: D = None
        self.txt = txt

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

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

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

e = A("e")
b = B("b")
j = C("j")
m = D("m")

e.t = m
b.t = m
j.o = b
j.p = m
m.o = j
m.y = b
assert e.t.o.o.txt == "b"