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

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

k = A("k")
h = B("h")
a = B("a")
l = B("l")
c = A("c")
d = A("d")

k.y = c
k.t = a
h.p = c
h.s = l
a.p = c
a.s = l
l.p = k
l.s = h
c.y = d
c.t = h
d.y = k
d.t = h
assert h.s.s.s.p.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.t: B = None
        self.txt = txt

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

k = A("k")
h = B("h")
a = B("a")
l = B("l")
c = A("c")
d = A("d")

k.y = c
k.t = a
h.p = c
h.s = l
a.p = c
a.s = l
l.p = k
l.s = h
c.y = d
c.t = h
d.y = k
d.t = h
assert h.s.s.s.p.y.txt == "c"