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

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

c = A("c")
d = B("d")
n = A("n")
b = B("b")
j = B("j")
m = B("m")
f = B("f")

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

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

c = A("c")
d = B("d")
n = A("n")
b = B("b")
j = B("j")
m = B("m")
f = B("f")

c.y = b
d.y = n
n.y = f
b.y = c
j.y = c
m.y = c
f.y = c
assert c.y.y.y.y.txt == "c"