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

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

e = A("e")
g = B("g")
a = B("a")
i = B("i")
k = B("k")

e.p = a
g.o = k
g.y = i
a.o = k
a.y = k
i.o = g
i.y = g
k.o = g
k.y = i
assert e.p.o.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.txt = txt

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

e = A("e")
g = B("g")
a = B("a")
i = B("i")
k = B("k")

e.p = a
g.o = k
g.y = i
a.o = k
a.y = k
i.o = g
i.y = g
k.o = g
k.y = i
assert e.p.o.y.y.txt == "g"