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

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

i = A("i")
a = B("a")
e = A("e")
f = B("f")
j = B("j")
m = B("m")
d = B("d")
l = A("l")
b = B("b")

i.y = l
a.u = m
a.x = d
e.y = i
f.u = m
f.x = b
j.u = f
j.x = d
m.u = b
m.x = d
d.u = f
d.x = a
l.y = i
b.u = m
b.x = a
assert e.y.y.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.txt = txt

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

i = A("i")
a = B("a")
e = A("e")
f = B("f")
j = B("j")
m = B("m")
d = B("d")
l = A("l")
b = B("b")

i.y = l
a.u = m
a.x = d
e.y = i
f.u = m
f.x = b
j.u = f
j.x = d
m.u = b
m.x = d
d.u = f
d.x = a
l.y = i
b.u = m
b.x = a
assert e.y.y.y.y.y.txt == "i"