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

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

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

j = A("j")
n = B("n")
k = C("k")
h = B("h")
a = C("a")
g = A("g")

j.w = k
n.s = g
k.o = n
k.v = a
k.y = a
h.s = g
a.o = n
a.v = k
a.y = k
g.w = a
assert k.v.v.y.o.s.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.txt = txt

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

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

j = A("j")
n = B("n")
k = C("k")
h = B("h")
a = C("a")
g = A("g")

j.w = k
n.s = g
k.o = n
k.v = a
k.y = a
h.s = g
a.o = n
a.v = k
a.y = k
g.w = a
assert k.v.v.y.o.s.w.txt == "a"