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

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

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

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

l.u = n
l.q = m
f.t = l
f.y = m
b.x = f
b.t = a
a.x = f
a.t = b
k.x = f
k.t = a
n.x = f
n.t = b
m.u = n
m.q = l
assert f.y.u.x.t.q.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.q: A = None
        self.txt = txt

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

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

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

l.u = n
l.q = m
f.t = l
f.y = m
b.x = f
b.t = a
a.x = f
a.t = b
k.x = f
k.t = a
n.x = f
n.t = b
m.u = n
m.q = l
assert f.y.u.x.t.q.txt == "m"