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

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

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

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

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

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

m.y = l
c.o = k
d.o = m
n.y = j
g.y = l
l.o = n
b.y = l
k.y = d
j.o = k
assert l.o.y.o.y.o.y.txt == "l"