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

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

d = A("d")
n = B("n")
e = A("e")
l = B("l")
c = A("c")
k = A("k")
f = A("f")
m = B("m")
j = A("j")

d.q = f
n.o = d
n.x = l
e.q = f
l.o = f
l.x = m
c.q = d
k.q = f
f.q = d
m.o = d
m.x = n
j.q = c
assert c.q.q.q.q.q.q.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.txt = txt

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

d = A("d")
n = B("n")
e = A("e")
l = B("l")
c = A("c")
k = A("k")
f = A("f")
m = B("m")
j = A("j")

d.q = f
n.o = d
n.x = l
e.q = f
l.o = f
l.x = m
c.q = d
k.q = f
f.q = d
m.o = d
m.x = n
j.q = c
assert c.q.q.q.q.q.q.q.q.txt == "f"