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

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

m = A("m")
g = B("g")
k = B("k")
l = B("l")
j = B("j")
b = A("b")
c = A("c")

m.v = j
g.y = j
k.y = l
l.y = j
j.y = g
b.v = j
c.v = l
assert j.y.y.y.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.txt = txt

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

m = A("m")
g = B("g")
k = B("k")
l = B("l")
j = B("j")
b = A("b")
c = A("c")

m.v = j
g.y = j
k.y = l
l.y = j
j.y = g
b.v = j
c.v = l
assert j.y.y.y.y.y.y.txt == "j"