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.v: A = None
        self.txt = txt

h = A("h")
e = B("e")
j = B("j")
g = B("g")
f = B("f")
k = A("k")
d = B("d")
i = A("i")
a = A("a")
b = A("b")

h.y = i
e.u = g
e.v = k
j.u = g
j.v = i
g.u = f
g.v = a
f.u = e
f.v = i
k.y = h
d.u = f
d.v = i
i.y = a
a.y = i
b.y = i
assert b.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.v: A = None
        self.txt = txt

h = A("h")
e = B("e")
j = B("j")
g = B("g")
f = B("f")
k = A("k")
d = B("d")
i = A("i")
a = A("a")
b = A("b")

h.y = i
e.u = g
e.v = k
j.u = g
j.v = i
g.u = f
g.v = a
f.u = e
f.v = i
k.y = h
d.u = f
d.v = i
i.y = a
a.y = i
b.y = i
assert b.y.y.y.txt == "i"