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

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

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

f = A("f")
m = B("m")
l = C("l")
j = B("j")
a = B("a")
n = B("n")
b = B("b")
g = A("g")

f.q = b
m.v = l
m.t = b
l.s = b
l.u = m
j.v = l
j.t = b
a.v = l
a.t = b
n.v = l
n.t = m
b.v = l
b.t = m
g.q = a
assert b.v.s.t.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.txt = txt

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

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

f = A("f")
m = B("m")
l = C("l")
j = B("j")
a = B("a")
n = B("n")
b = B("b")
g = A("g")

f.q = b
m.v = l
m.t = b
l.s = b
l.u = m
j.v = l
j.t = b
a.v = l
a.t = b
n.v = l
n.t = m
b.v = l
b.t = m
g.q = a
assert b.v.s.t.txt == "m"