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

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

f = A("f")
j = B("j")
b = A("b")
e = B("e")
n = B("n")
m = B("m")
h = B("h")
k = B("k")
a = A("a")

f.y = k
f.v = h
j.o = a
b.y = k
b.v = h
e.o = f
n.o = f
m.o = a
h.o = a
k.o = b
a.y = j
a.v = k
assert k.o.y.o.y.o.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.v: B = None
        self.txt = txt

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

f = A("f")
j = B("j")
b = A("b")
e = B("e")
n = B("n")
m = B("m")
h = B("h")
k = B("k")
a = A("a")

f.y = k
f.v = h
j.o = a
b.y = k
b.v = h
e.o = f
n.o = f
m.o = a
h.o = a
k.o = b
a.y = j
a.v = k
assert k.o.y.o.y.o.y.txt == "k"