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

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

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

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

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

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

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

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

a.q = g
a.u = m
a.y = m
b.r = l
b.u = g
l.s = a
l.u = c
g.q = c
g.u = b
g.y = n
n.r = l
n.u = c
c.q = a
c.u = n
c.y = m
f.r = l
f.u = a
m.r = l
m.u = g
assert b.r.u.q.txt == "a"