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

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

g = A("g")
h = B("h")
f = A("f")
d = A("d")
c = A("c")
l = B("l")
i = B("i")

g.t = d
g.y = i
h.t = i
h.q = l
f.t = c
f.y = h
d.t = g
d.y = i
c.t = d
c.y = l
l.t = h
l.q = i
i.t = l
i.q = l
assert f.t.t.t.y.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.y: B = None
        self.txt = txt

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

g = A("g")
h = B("h")
f = A("f")
d = A("d")
c = A("c")
l = B("l")
i = B("i")

g.t = d
g.y = i
h.t = i
h.q = l
f.t = c
f.y = h
d.t = g
d.y = i
c.t = d
c.y = l
l.t = h
l.q = i
i.t = l
i.q = l
assert f.t.t.t.y.t.txt == "l"