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

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

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

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

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

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

h.w = c
j.w = h
l.w = h
c.w = h
assert j.w.w.w.w.txt == "c"