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

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

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

c = A("c")
g = B("g")
i = C("i")
e = A("e")
l = B("l")

c.o = e
g.r = i
g.t = i
i.q = l
i.r = g
e.o = c
l.r = i
l.t = i
assert i.r.r.q.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.txt = txt

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

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

c = A("c")
g = B("g")
i = C("i")
e = A("e")
l = B("l")

c.o = e
g.r = i
g.t = i
i.q = l
i.r = g
e.o = c
l.r = i
l.t = i
assert i.r.r.q.txt == "l"