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

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

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

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

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

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

b.q = d
b.t = d
f.w = i
l.w = c
d.w = i
h.q = a
h.t = a
g.w = n
i.w = f
n.w = a
c.w = f
a.w = d
assert i.w.w.w.txt == "f"