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

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

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

a = A("a")
g = B("g")
c = C("c")
i = A("i")
b = C("b")
l = A("l")
j = B("j")
m = A("m")
h = A("h")
n = B("n")

a.q = j
a.o = l
g.o = b
g.u = a
c.r = g
c.o = g
c.p = b
i.q = n
i.o = l
b.r = j
b.o = j
b.p = c
l.q = n
l.o = h
j.o = c
j.u = h
m.q = g
m.o = i
h.q = n
h.o = i
n.o = c
n.u = a
assert c.p.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.o: A = None
        self.txt = txt

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

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

a = A("a")
g = B("g")
c = C("c")
i = A("i")
b = C("b")
l = A("l")
j = B("j")
m = A("m")
h = A("h")
n = B("n")

a.q = j
a.o = l
g.o = b
g.u = a
c.r = g
c.o = g
c.p = b
i.q = n
i.o = l
b.r = j
b.o = j
b.p = c
l.q = n
l.o = h
j.o = c
j.u = h
m.q = g
m.o = i
h.q = n
h.o = i
n.o = c
n.u = a
assert c.p.p.p.txt == "b"