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

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

e = A("e")
l = B("l")
a = A("a")
f = B("f")
c = B("c")

e.w = a
e.y = c
l.x = f
a.w = e
a.y = f
f.x = l
c.x = f
assert c.x.x.x.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.y: B = None
        self.txt = txt

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

e = A("e")
l = B("l")
a = A("a")
f = B("f")
c = B("c")

e.w = a
e.y = c
l.x = f
a.w = e
a.y = f
f.x = l
c.x = f
assert c.x.x.x.x.x.txt == "f"