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

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

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

a = A("a")
l = B("l")
g = C("g")
f = C("f")
b = B("b")
i = A("i")
d = B("d")
c = A("c")

a.s = c
a.z = g
l.r = a
l.s = i
l.y = d
g.u = c
g.x = d
f.u = a
f.x = b
b.r = a
b.s = c
b.y = l
i.s = a
i.z = g
d.r = i
d.s = a
d.y = l
c.s = a
c.z = g
assert b.y.s.s.s.s.z.u.txt == "
class A:
    def __init__(self, txt: str):
        self.s: A = None
        self.z: C = None
        self.txt = txt

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

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

a = A("a")
l = B("l")
g = C("g")
f = C("f")
b = B("b")
i = A("i")
d = B("d")
c = A("c")

a.s = c
a.z = g
l.r = a
l.s = i
l.y = d
g.u = c
g.x = d
f.u = a
f.x = b
b.r = a
b.s = c
b.y = l
i.s = a
i.z = g
d.r = i
d.s = a
d.y = l
c.s = a
c.z = g
assert b.y.s.s.s.s.z.u.txt == "c"