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

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

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

h = A("h")
g = B("g")
b = C("b")
l = C("l")
k = A("k")
i = B("i")

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

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

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

h = A("h")
g = B("g")
b = C("b")
l = C("l")
k = A("k")
i = B("i")

h.o = k
g.y = l
b.o = h
b.w = i
b.p = i
l.o = h
l.w = i
l.p = g
k.o = h
i.y = l
assert b.p.y.w.y.w.txt == "i"