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

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

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

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

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

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

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

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

f.z = h
f.p = g
f.t = a
i.p = g
i.z = g
i.x = f
a.y = i
a.s = k
h.z = f
h.p = i
h.t = e
e.y = i
e.s = k
g.p = i
g.z = i
g.x = f
k.y = i
k.s = a
assert h.z.p.z.x.txt == "f"