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

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

e = A("e")
f = B("f")
j = A("j")
a = A("a")
d = A("d")
i = A("i")
k = B("k")
c = A("c")
l = B("l")
h = A("h")

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

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

e = A("e")
f = B("f")
j = A("j")
a = A("a")
d = A("d")
i = A("i")
k = B("k")
c = A("c")
l = B("l")
h = A("h")

e.x = f
e.y = a
f.s = k
j.x = l
j.y = c
a.x = f
a.y = h
d.x = l
d.y = a
i.x = k
i.y = h
k.s = l
c.x = l
c.y = i
l.s = k
h.x = f
h.y = d
assert h.y.x.s.s.s.s.s.s.s.s.txt == "l"