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

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

c = A("c")
m = B("m")
a = A("a")
e = B("e")

c.o = a
c.t = m
m.v = c
a.o = c
a.t = e
e.v = a
assert e.v.t.v.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.t: B = None
        self.txt = txt

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

c = A("c")
m = B("m")
a = A("a")
e = B("e")

c.o = a
c.t = m
m.v = c
a.o = c
a.t = e
e.v = a
assert e.v.t.v.o.txt == "c"