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

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

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

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

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

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

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

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

j.z = d
j.s = d
j.x = h
f.r = g
i.s = j
d.s = h
g.r = f
k.z = d
k.s = d
k.x = h
h.z = d
h.s = d
h.x = k
assert i.s.z.s.txt == "h"