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

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

j = A("j")
c = B("c")
i = A("i")
n = A("n")
m = B("m")
l = A("l")
k = B("k")
f = B("f")

j.t = c
c.y = j
c.x = m
i.t = c
n.t = k
m.y = n
m.x = f
l.t = m
k.y = l
k.x = c
f.y = j
f.x = c
assert i.t.x.y.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

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

j = A("j")
c = B("c")
i = A("i")
n = A("n")
m = B("m")
l = A("l")
k = B("k")
f = B("f")

j.t = c
c.y = j
c.x = m
i.t = c
n.t = k
m.y = n
m.x = f
l.t = m
k.y = l
k.x = c
f.y = j
f.x = c
assert i.t.x.y.txt == "n"