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

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

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

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

j = A("j")
l = B("l")
f = C("f")
b = D("b")
c = A("c")

j.w = f
l.s = c
f.x = l
b.w = c
b.p = c
b.v = f
c.w = f
assert j.w.x.s.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.txt = txt

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

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

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

j = A("j")
l = B("l")
f = C("f")
b = D("b")
c = A("c")

j.w = f
l.s = c
f.x = l
b.w = c
b.p = c
b.v = f
c.w = f
assert j.w.x.s.txt == "c"