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

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

g = A("g")
c = B("c")
l = A("l")
j = B("j")
k = A("k")
d = B("d")
m = B("m")
b = A("b")
h = B("h")

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

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

g = A("g")
c = B("c")
l = A("l")
j = B("j")
k = A("k")
d = B("d")
m = B("m")
b = A("b")
h = B("h")

g.y = h
g.t = d
c.w = l
l.y = d
l.t = h
j.w = b
k.y = h
k.t = m
d.w = b
m.w = b
b.y = c
b.t = c
h.w = g
assert l.t.w.t.w.txt == "b"