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

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

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

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

i = A("i")
h = B("h")
j = C("j")
f = D("f")

i.w = h
i.u = h
h.v = f
j.r = i
j.u = f
f.y = j
f.s = h
assert h.v.s.v.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.u: B = None
        self.txt = txt

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

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

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

i = A("i")
h = B("h")
j = C("j")
f = D("f")

i.w = h
i.u = h
h.v = f
j.r = i
j.u = f
f.y = j
f.s = h
assert h.v.s.v.txt == "f"