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

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

j = A("j")
g = B("g")
b = B("b")
a = B("a")
n = B("n")
m = A("m")
f = A("f")
h = A("h")
i = A("i")

j.y = m
j.u = f
g.v = f
b.v = j
a.v = i
n.v = i
m.y = f
m.u = h
f.y = j
f.u = m
h.y = m
h.u = m
i.y = f
i.u = f
assert i.u.u.u.u.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.u: A = None
        self.txt = txt

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

j = A("j")
g = B("g")
b = B("b")
a = B("a")
n = B("n")
m = A("m")
f = A("f")
h = A("h")
i = A("i")

j.y = m
j.u = f
g.v = f
b.v = j
a.v = i
n.v = i
m.y = f
m.u = h
f.y = j
f.u = m
h.y = m
h.u = m
i.y = f
i.u = f
assert i.u.u.u.u.y.txt == "f"