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

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

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

c = A("c")
n = B("n")
j = C("j")
e = C("e")
f = C("f")
k = A("k")
b = A("b")
g = A("g")
d = A("d")
l = C("l")

c.q = n
c.o = j
n.o = d
n.q = f
j.w = b
e.w = g
f.w = b
k.q = n
k.o = l
b.q = n
b.o = e
g.q = n
g.o = f
d.q = n
d.o = j
l.w = d
assert l.w.q.q.w.o.w.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.o: C = None
        self.txt = txt

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

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

c = A("c")
n = B("n")
j = C("j")
e = C("e")
f = C("f")
k = A("k")
b = A("b")
g = A("g")
d = A("d")
l = C("l")

c.q = n
c.o = j
n.o = d
n.q = f
j.w = b
e.w = g
f.w = b
k.q = n
k.o = l
b.q = n
b.o = e
g.q = n
g.o = f
d.q = n
d.o = j
l.w = d
assert l.w.q.q.w.o.w.txt == "g"