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

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

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

h.v = i
h.x = i
g.z = j
i.w = f
f.s = b
b.v = i
b.x = i
j.z = g
assert i.w.s.v.w.s.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.x: C = None
        self.txt = txt

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

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

h.v = i
h.x = i
g.z = j
i.w = f
f.s = b
b.v = i
b.x = i
j.z = g
assert i.w.s.v.w.s.v.txt == "i"