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

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

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

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

j.v = e
j.w = l
g.t = c
g.q = l
m.w = c
e.t = c
e.q = l
k.t = j
k.q = l
d.t = c
d.q = n
l.t = c
l.q = k
n.t = j
n.q = e
c.v = k
c.w = g
assert d.q.q.q.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.w: B = None
        self.txt = txt

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

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

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

j.v = e
j.w = l
g.t = c
g.q = l
m.w = c
e.t = c
e.q = l
k.t = j
k.q = l
d.t = c
d.q = n
l.t = c
l.q = k
n.t = j
n.q = e
c.v = k
c.w = g
assert d.q.q.q.q.q.txt == "l"