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

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

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

i = A("i")
n = B("n")
g = C("g")
k = B("k")
a = A("a")
l = C("l")

i.o = k
i.q = l
n.p = l
g.u = k
g.w = l
k.p = g
a.o = k
a.q = g
l.u = n
l.w = g
assert g.w.u.p.u.p.u.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.q: C = None
        self.txt = txt

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

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

i = A("i")
n = B("n")
g = C("g")
k = B("k")
a = A("a")
l = C("l")

i.o = k
i.q = l
n.p = l
g.u = k
g.w = l
k.p = g
a.o = k
a.q = g
l.u = n
l.w = g
assert g.w.u.p.u.p.u.txt == "n"