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

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

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

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

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

n.t = m
n.y = j
n.w = j
e.y = j
e.t = m
j.s = m
m.r = e
m.y = e
assert j.s.r.t.y.txt == "
class A:
    def __init__(self, txt: str):
        self.t: D = None
        self.y: C = None
        self.w: C = None
        self.txt = txt

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

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

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

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

n.t = m
n.y = j
n.w = j
e.y = j
e.t = m
j.s = m
m.r = e
m.y = e
assert j.s.r.t.y.txt == "e"