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

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

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

g = A("g")
k = B("k")
m = C("m")
e = C("e")
h = A("h")

g.o = h
k.y = g
m.u = e
e.u = m
h.o = g
assert g.o.o.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.txt = txt

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

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

g = A("g")
k = B("k")
m = C("m")
e = C("e")
h = A("h")

g.o = h
k.y = g
m.u = e
e.u = m
h.o = g
assert g.o.o.o.o.txt == "g"