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

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

j = A("j")
b = B("b")
h = A("h")
i = B("i")
c = A("c")
e = B("e")
d = B("d")
l = B("l")

j.t = l
j.s = b
b.y = d
b.s = l
h.t = d
h.s = d
i.y = d
i.s = d
c.t = e
c.s = b
e.y = l
e.s = i
d.y = l
d.s = b
l.y = e
l.s = i
assert c.s.s.s.s.s.y.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.s: B = None
        self.txt = txt

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

j = A("j")
b = B("b")
h = A("h")
i = B("i")
c = A("c")
e = B("e")
d = B("d")
l = B("l")

j.t = l
j.s = b
b.y = d
b.s = l
h.t = d
h.s = d
i.y = d
i.s = d
c.t = e
c.s = b
e.y = l
e.s = i
d.y = l
d.s = b
l.y = e
l.s = i
assert c.s.s.s.s.s.y.txt == "d"