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

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

m = A("m")
h = B("h")
l = B("l")
j = A("j")
c = B("c")
k = A("k")

m.x = k
h.w = l
l.w = h
j.x = k
c.w = h
k.x = m
assert j.x.x.x.x.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.txt = txt

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

m = A("m")
h = B("h")
l = B("l")
j = A("j")
c = B("c")
k = A("k")

m.x = k
h.w = l
l.w = h
j.x = k
c.w = h
k.x = m
assert j.x.x.x.x.x.x.txt == "m"