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

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

j = A("j")
a = B("a")
m = B("m")
e = B("e")
i = A("i")
b = A("b")
n = A("n")
c = A("c")

j.r = e
j.t = b
a.y = i
m.y = b
e.y = i
i.r = m
i.t = j
b.r = a
b.t = j
n.r = e
n.t = b
c.r = e
c.t = n
assert e.y.t.r.y.t.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.t: A = None
        self.txt = txt

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

j = A("j")
a = B("a")
m = B("m")
e = B("e")
i = A("i")
b = A("b")
n = A("n")
c = A("c")

j.r = e
j.t = b
a.y = i
m.y = b
e.y = i
i.r = m
i.t = j
b.r = a
b.t = j
n.r = e
n.t = b
c.r = e
c.t = n
assert e.y.t.r.y.t.txt == "j"