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

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

c = A("c")
a = B("a")
h = B("h")
b = A("b")
i = B("i")
k = B("k")
e = B("e")
g = B("g")
j = A("j")

c.w = j
a.z = j
h.z = c
b.w = c
i.z = j
k.z = j
e.z = j
g.z = c
j.w = c
assert h.z.w.w.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.z: A = None
        self.txt = txt

c = A("c")
a = B("a")
h = B("h")
b = A("b")
i = B("i")
k = B("k")
e = B("e")
g = B("g")
j = A("j")

c.w = j
a.z = j
h.z = c
b.w = c
i.z = j
k.z = j
e.z = j
g.z = c
j.w = c
assert h.z.w.w.w.w.w.w.txt == "c"