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

class B:
    def __init__(self, txt: str):
        self.y: D = None
        self.w: A = None
        self.s: D = 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.q: B = None
        self.u: A = None
        self.txt = txt

n = A("n")
c = B("c")
l = C("l")
j = D("j")

n.y = j
c.y = j
c.s = j
c.w = n
l.w = j
j.q = c
j.u = n
assert j.q.y.q.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.y: D = None
        self.w: A = None
        self.s: D = 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.q: B = None
        self.u: A = None
        self.txt = txt

n = A("n")
c = B("c")
l = C("l")
j = D("j")

n.y = j
c.y = j
c.s = j
c.w = n
l.w = j
j.q = c
j.u = n
assert j.q.y.q.y.txt == "j"