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

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

f = A("f")
j = B("j")
b = A("b")
k = A("k")
a = A("a")
d = B("d")
n = A("n")

f.z = d
f.t = d
j.w = d
b.z = j
b.t = d
k.z = d
k.t = j
a.z = j
a.t = d
d.w = j
n.z = d
n.t = j
assert d.w.w.w.w.w.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.t: B = None
        self.txt = txt

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

f = A("f")
j = B("j")
b = A("b")
k = A("k")
a = A("a")
d = B("d")
n = A("n")

f.z = d
f.t = d
j.w = d
b.z = j
b.t = d
k.z = d
k.t = j
a.z = j
a.t = d
d.w = j
n.z = d
n.t = j
assert d.w.w.w.w.w.w.w.txt == "j"