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

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

d = A("d")
m = B("m")
k = B("k")
e = B("e")

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

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

d = A("d")
m = B("m")
k = B("k")
e = B("e")

d.t = k
d.u = e
m.v = d
m.t = k
k.v = d
k.t = m
e.v = d
e.t = k
assert d.t.v.t.txt == "k"