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

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

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

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

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

e.y = j
e.o = j
e.u = m
g.p = m
g.s = e
j.u = m
m.p = j
assert e.u.p.u.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.o: C = None
        self.u: D = None
        self.txt = txt

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

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

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

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

e.y = j
e.o = j
e.u = m
g.p = m
g.s = e
j.u = m
m.p = j
assert e.u.p.u.txt == "m"