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

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

d = A("d")
i = B("i")
e = A("e")
b = B("b")

d.u = b
d.v = b
i.w = b
i.t = b
e.u = b
e.v = i
b.w = i
b.t = i
assert i.w.t.w.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.v: B = None
        self.txt = txt

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

d = A("d")
i = B("i")
e = A("e")
b = B("b")

d.u = b
d.v = b
i.w = b
i.t = b
e.u = b
e.v = i
b.w = i
b.t = i
assert i.w.t.w.txt == "b"