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

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

a = A("a")
h = B("h")
i = B("i")
j = A("j")
g = A("g")
f = A("f")
b = A("b")
l = A("l")

a.y = i
a.t = b
h.r = i
i.r = h
j.y = i
j.t = g
g.y = i
g.t = l
f.y = i
f.t = g
b.y = h
b.t = a
l.y = i
l.t = a
assert j.t.t.y.r.r.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.t: A = None
        self.txt = txt

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

a = A("a")
h = B("h")
i = B("i")
j = A("j")
g = A("g")
f = A("f")
b = A("b")
l = A("l")

a.y = i
a.t = b
h.r = i
i.r = h
j.y = i
j.t = g
g.y = i
g.t = l
f.y = i
f.t = g
b.y = h
b.t = a
l.y = i
l.t = a
assert j.t.t.y.r.r.r.r.r.txt == "h"