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

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

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

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

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

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

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