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

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

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

l.p = m
l.t = a
e.y = l
m.y = l
a.p = m
a.t = l
assert e.y.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.t: A = None
        self.txt = txt

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

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

l.p = m
l.t = a
e.y = l
m.y = l
a.p = m
a.t = l
assert e.y.t.t.txt == "l"