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

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

i = A("i")
c = B("c")
f = A("f")
k = B("k")

i.w = f
i.u = f
c.x = i
c.v = i
f.w = i
f.u = i
k.x = f
k.v = i
assert i.w.u.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.u: A = None
        self.txt = txt

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

i = A("i")
c = B("c")
f = A("f")
k = B("k")

i.w = f
i.u = f
c.x = i
c.v = i
f.w = i
f.u = i
k.x = f
k.v = i
assert i.w.u.w.txt == "f"