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

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

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

a = A("a")
i = B("i")
e = C("e")
g = B("g")

a.q = g
a.o = g
i.v = a
i.r = a
i.u = g
e.r = a
e.o = a
g.v = a
g.r = a
g.u = i
assert g.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.o: B = None
        self.txt = txt

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

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

a = A("a")
i = B("i")
e = C("e")
g = B("g")

a.q = g
a.o = g
i.v = a
i.r = a
i.u = g
e.r = a
e.o = a
g.v = a
g.r = a
g.u = i
assert g.u.u.u.txt == "i"