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

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

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

a = A("a")
i = B("i")
f = C("f")
m = C("m")
d = A("d")
n = C("n")
h = C("h")
k = B("k")
b = C("b")
g = C("g")

a.y = i
a.s = d
i.x = d
i.t = k
i.s = k
f.u = a
f.z = i
m.u = d
m.z = i
d.y = k
d.s = a
n.u = d
n.z = i
h.u = d
h.z = i
k.x = d
k.t = i
k.s = i
b.u = d
b.z = i
g.u = d
g.z = i
assert n.z.x.s.s.s.s.y.t.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.s: A = None
        self.txt = txt

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

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

a = A("a")
i = B("i")
f = C("f")
m = C("m")
d = A("d")
n = C("n")
h = C("h")
k = B("k")
b = C("b")
g = C("g")

a.y = i
a.s = d
i.x = d
i.t = k
i.s = k
f.u = a
f.z = i
m.u = d
m.z = i
d.y = k
d.s = a
n.u = d
n.z = i
h.u = d
h.z = i
k.x = d
k.t = i
k.s = i
b.u = d
b.z = i
g.u = d
g.z = i
assert n.z.x.s.s.s.s.y.t.txt == "i"