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

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

e = A("e")
i = B("i")
j = B("j")
c = A("c")

e.y = c
i.y = e
i.x = e
j.y = e
j.x = e
c.y = e
assert e.y.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.txt = txt

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

e = A("e")
i = B("i")
j = B("j")
c = A("c")

e.y = c
i.y = e
i.x = e
j.y = e
j.x = e
c.y = e
assert e.y.y.y.y.txt == "e"