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

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

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

j = A("j")
e = B("e")
h = C("h")
k = C("k")
f = A("f")
n = A("n")
g = B("g")
c = A("c")
d = B("d")

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

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

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

j = A("j")
e = B("e")
h = C("h")
k = C("k")
f = A("f")
n = A("n")
g = B("g")
c = A("c")
d = B("d")

j.z = c
j.s = k
e.r = f
e.z = d
h.z = d
h.x = n
k.z = d
k.x = n
f.z = c
f.s = k
n.z = j
n.s = k
g.r = j
g.z = d
c.z = f
c.s = k
d.r = n
d.z = g
assert e.r.s.z.z.r.z.s.z.z.txt == "g"