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

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

j = A("j")
i = B("i")
d = B("d")
g = B("g")
c = B("c")
n = B("n")

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

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

j = A("j")
i = B("i")
d = B("d")
g = B("g")
c = B("c")
n = B("n")

j.t = d
j.q = n
i.y = d
d.y = n
g.y = d
c.y = d
n.y = g
assert j.q.y.y.y.y.txt == "g"