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

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

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

h = A("h")
l = B("l")
k = C("k")
g = A("g")
c = B("c")

h.s = k
h.q = k
h.t = g
l.o = k
k.u = c
g.s = k
g.q = k
g.t = h
c.o = k
assert h.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.q: C = None
        self.t: A = None
        self.txt = txt

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

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

h = A("h")
l = B("l")
k = C("k")
g = A("g")
c = B("c")

h.s = k
h.q = k
h.t = g
l.o = k
k.u = c
g.s = k
g.q = k
g.t = h
c.o = k
assert h.t.t.t.txt == "g"