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

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

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

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

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

j.w = n
f.v = n
f.u = n
n.y = f
c.y = n
c.w = n
c.s = f
assert j.w.y.u.y.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.txt = txt

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

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

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

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

j.w = n
f.v = n
f.u = n
n.y = f
c.y = n
c.w = n
c.s = f
assert j.w.y.u.y.txt == "f"