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

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

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

g = A("g")
k = B("k")
c = C("c")
f = B("f")
m = A("m")
i = C("i")
l = B("l")

g.q = f
k.w = m
k.r = f
k.t = g
c.s = g
c.t = m
c.p = i
f.w = g
f.r = k
f.t = m
m.q = l
i.s = g
i.t = g
i.p = c
l.w = m
l.r = k
l.t = g
assert l.t.q.t.q.w.q.w.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.txt = txt

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

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

g = A("g")
k = B("k")
c = C("c")
f = B("f")
m = A("m")
i = C("i")
l = B("l")

g.q = f
k.w = m
k.r = f
k.t = g
c.s = g
c.t = m
c.p = i
f.w = g
f.r = k
f.t = m
m.q = l
i.s = g
i.t = g
i.p = c
l.w = m
l.r = k
l.t = g
assert l.t.q.t.q.w.q.w.txt == "m"