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

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

class C:
    def __init__(self, txt: str):
        self.r: C = None
        self.s: B = None
        self.txt = txt

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

f.q = k
f.v = k
e.y = f
e.u = f
e.q = j
j.r = d
j.s = m
c.r = d
c.s = m
n.r = d
n.s = e
k.q = f
k.v = f
d.r = n
d.s = e
m.y = k
m.q = d
m.u = f
a.r = n
a.s = m
assert f.q.q.q.v.v.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.v: A = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.r: C = None
        self.s: B = None
        self.txt = txt

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

f.q = k
f.v = k
e.y = f
e.u = f
e.q = j
j.r = d
j.s = m
c.r = d
c.s = m
n.r = d
n.s = e
k.q = f
k.v = f
d.r = n
d.s = e
m.y = k
m.q = d
m.u = f
a.r = n
a.s = m
assert f.q.q.q.v.v.v.v.v.txt == "f"