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

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

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

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

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

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

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

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

m.v = n
m.q = e
e.y = a
l.q = g
a.q = j
b.y = j
g.q = j
n.v = m
n.q = e
j.q = a
assert b.y.q.q.q.txt == "a"