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

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

j = A("j")
k = B("k")
e = B("e")
f = B("f")
g = A("g")
l = B("l")
h = A("h")

j.q = e
j.x = f
k.t = j
k.y = l
e.t = h
e.y = k
f.t = j
f.y = k
g.q = k
g.x = e
l.t = h
l.y = k
h.q = k
h.x = e
assert j.x.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.x: B = None
        self.txt = txt

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

j = A("j")
k = B("k")
e = B("e")
f = B("f")
g = A("g")
l = B("l")
h = A("h")

j.q = e
j.x = f
k.t = j
k.y = l
e.t = h
e.y = k
f.t = j
f.y = k
g.q = k
g.x = e
l.t = h
l.y = k
h.q = k
h.x = e
assert j.x.y.y.y.txt == "k"