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

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

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

k = A("k")
g = B("g")
i = C("i")
b = C("b")
n = A("n")
c = B("c")

k.y = b
k.o = b
k.p = i
g.w = i
i.s = b
b.s = i
n.y = i
n.o = i
n.p = b
c.w = b
assert i.s.s.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.p: C = None
        self.o: C = None
        self.txt = txt

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

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

k = A("k")
g = B("g")
i = C("i")
b = C("b")
n = A("n")
c = B("c")

k.y = b
k.o = b
k.p = i
g.w = i
i.s = b
b.s = i
n.y = i
n.o = i
n.p = b
c.w = b
assert i.s.s.s.s.txt == "i"