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

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

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

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

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

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

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

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

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