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

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

i = A("i")
a = B("a")
c = A("c")
l = B("l")
g = B("g")
k = B("k")

i.o = c
a.u = g
a.p = c
c.o = i
l.u = a
l.p = i
g.u = k
g.p = i
k.u = g
k.p = i
assert i.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.u: B = None
        self.p: A = None
        self.txt = txt

i = A("i")
a = B("a")
c = A("c")
l = B("l")
g = B("g")
k = B("k")

i.o = c
a.u = g
a.p = c
c.o = i
l.u = a
l.p = i
g.u = k
g.p = i
k.u = g
k.p = i
assert i.o.o.o.txt == "c"