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

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

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

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

e.w = g
j.x = k
j.s = e
g.w = f
g.p = e
g.s = h
h.w = k
f.x = k
f.s = h
a.x = g
a.s = h
k.w = f
k.p = h
k.s = h
c.x = k
c.s = e
assert j.x.p.w.w.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.x: C = None
        self.s: A = None
        self.txt = txt

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

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

e.w = g
j.x = k
j.s = e
g.w = f
g.p = e
g.s = h
h.w = k
f.x = k
f.s = h
a.x = g
a.s = h
k.w = f
k.p = h
k.s = h
c.x = k
c.s = e
assert j.x.p.w.w.s.w.txt == "k"