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

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

class E:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

f = A("f")
k = B("k")
i = C("i")
g = D("g")
e = E("e")
h = C("h")

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

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

class E:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

f = A("f")
k = B("k")
i = C("i")
g = D("g")
e = E("e")
h = C("h")

f.v = h
k.s = f
k.v = i
k.x = i
k.z = g
i.w = g
g.w = k
g.z = k
e.t = k
h.w = g
assert f.v.w.w.s.v.w.txt == "g"