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

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

i = A("i")
l = B("l")
e = A("e")
h = B("h")
b = A("b")
d = A("d")
c = A("c")

i.q = d
i.y = c
l.t = h
e.q = b
e.y = c
h.t = l
b.q = d
b.y = c
d.q = e
d.y = i
c.q = b
c.y = d
assert i.q.q.q.y.q.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.y: A = None
        self.txt = txt

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

i = A("i")
l = B("l")
e = A("e")
h = B("h")
b = A("b")
d = A("d")
c = A("c")

i.q = d
i.y = c
l.t = h
e.q = b
e.y = c
h.t = l
b.q = d
b.y = c
d.q = e
d.y = i
c.q = b
c.y = d
assert i.q.q.q.y.q.y.y.txt == "d"