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

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

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

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

h.y = i
h.r = j
e.w = j
f.z = e
f.v = h
j.w = e
b.z = e
b.v = i
g.y = i
g.r = e
i.y = h
i.r = e
k.y = g
k.r = e
assert f.z.w.w.w.w.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.r: B = None
        self.txt = txt

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

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

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

h.y = i
h.r = j
e.w = j
f.z = e
f.v = h
j.w = e
b.z = e
b.v = i
g.y = i
g.r = e
i.y = h
i.r = e
k.y = g
k.r = e
assert f.z.w.w.w.w.w.w.txt == "e"