class A:
    def __init__(self, txt: str):
        self.p: A = None
        self.s: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.z: C = None
        self.x: C = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.x: C = None
        self.u: A = None
        self.w: A = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.z: D = None
        self.v: B = None
        self.o: F = None
        self.u: A = None
        self.txt = txt

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

b = A("b")
c = B("c")
g = C("g")
f = D("f")
j = E("j")
a = F("a")
d = E("d")
l = A("l")
n = D("n")
e = C("e")

b.p = l
b.s = g
c.z = e
c.x = e
g.x = e
g.u = b
g.w = b
f.q = n
j.z = f
j.v = c
j.o = a
j.u = l
a.v = l
d.z = n
d.v = c
d.o = a
d.u = l
l.p = b
l.s = e
n.q = f
e.x = g
e.u = l
e.w = l
assert n.q.q.q.q.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.p: A = None
        self.s: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.z: C = None
        self.x: C = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.x: C = None
        self.u: A = None
        self.w: A = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.z: D = None
        self.v: B = None
        self.o: F = None
        self.u: A = None
        self.txt = txt

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

b = A("b")
c = B("c")
g = C("g")
f = D("f")
j = E("j")
a = F("a")
d = E("d")
l = A("l")
n = D("n")
e = C("e")

b.p = l
b.s = g
c.z = e
c.x = e
g.x = e
g.u = b
g.w = b
f.q = n
j.z = f
j.v = c
j.o = a
j.u = l
a.v = l
d.z = n
d.v = c
d.o = a
d.u = l
l.p = b
l.s = e
n.q = f
e.x = g
e.u = l
e.w = l
assert n.q.q.q.q.q.q.txt == "n"