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

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

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

h = A("h")
i = B("i")
l = C("l")
j = A("j")
n = C("n")

h.p = j
h.s = i
h.y = i
i.o = l
l.y = i
l.p = i
j.p = h
j.s = i
j.y = i
n.y = i
n.p = i
assert l.y.o.y.txt == "
class A:
    def __init__(self, txt: str):
        self.p: A = None
        self.s: B = None
        self.y: B = None
        self.txt = txt

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

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

h = A("h")
i = B("i")
l = C("l")
j = A("j")
n = C("n")

h.p = j
h.s = i
h.y = i
i.o = l
l.y = i
l.p = i
j.p = h
j.s = i
j.y = i
n.y = i
n.p = i
assert l.y.o.y.txt == "i"