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

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

f = A("f")
m = B("m")
h = B("h")
i = A("i")

f.v = m
f.t = h
m.r = h
m.y = i
h.r = m
h.y = i
i.v = h
i.t = h
assert m.r.r.r.y.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.t: B = None
        self.txt = txt

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

f = A("f")
m = B("m")
h = B("h")
i = A("i")

f.v = m
f.t = h
m.r = h
m.y = i
h.r = m
h.y = i
i.v = h
i.t = h
assert m.r.r.r.y.txt == "i"