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

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

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

j = A("j")
n = B("n")
a = C("a")
f = A("f")
i = A("i")
c = B("c")

j.w = n
j.s = f
j.q = i
n.r = c
n.s = a
n.p = i
a.y = c
a.z = c
a.s = f
f.w = c
f.s = j
f.q = i
i.w = c
i.s = f
i.q = j
c.r = n
c.s = a
c.p = f
assert j.w.p.s.w.s.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.s: A = None
        self.q: A = None
        self.txt = txt

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

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

j = A("j")
n = B("n")
a = C("a")
f = A("f")
i = A("i")
c = B("c")

j.w = n
j.s = f
j.q = i
n.r = c
n.s = a
n.p = i
a.y = c
a.z = c
a.s = f
f.w = c
f.s = j
f.q = i
i.w = c
i.s = f
i.q = j
c.r = n
c.s = a
c.p = f
assert j.w.p.s.w.s.txt == "a"