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

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

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

m = A("m")
l = B("l")
a = C("a")
g = A("g")
k = B("k")

m.t = a
l.q = m
l.w = k
l.v = a
a.q = k
a.o = m
g.t = a
k.q = m
k.w = l
k.v = a
assert m.t.q.q.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.txt = txt

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

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

m = A("m")
l = B("l")
a = C("a")
g = A("g")
k = B("k")

m.t = a
l.q = m
l.w = k
l.v = a
a.q = k
a.o = m
g.t = a
k.q = m
k.w = l
k.v = a
assert m.t.q.q.t.txt == "a"