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

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

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

class D:
    def __init__(self, txt: str):
        self.p: B = None
        self.o: E = None
        self.txt = txt

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

class F:
    def __init__(self, txt: str):
        self.t: E = None
        self.o: A = None
        self.r: C = None
        self.txt = txt

n = A("n")
k = B("k")
b = C("b")
l = D("l")
f = E("f")
j = F("j")
m = C("m")
c = D("c")
h = B("h")

n.q = c
k.t = f
b.p = l
b.z = f
b.u = c
b.s = n
l.p = h
l.o = f
f.z = h
j.t = f
j.o = n
j.r = b
m.p = l
m.u = l
m.z = f
m.s = n
c.p = k
c.o = f
h.t = f
assert f.z.t.z.t.z.t.z.t.txt == "
class A:
    def __init__(self, txt: str):
        self.q: D = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.p: B = None
        self.o: E = None
        self.txt = txt

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

class F:
    def __init__(self, txt: str):
        self.t: E = None
        self.o: A = None
        self.r: C = None
        self.txt = txt

n = A("n")
k = B("k")
b = C("b")
l = D("l")
f = E("f")
j = F("j")
m = C("m")
c = D("c")
h = B("h")

n.q = c
k.t = f
b.p = l
b.z = f
b.u = c
b.s = n
l.p = h
l.o = f
f.z = h
j.t = f
j.o = n
j.r = b
m.p = l
m.u = l
m.z = f
m.s = n
c.p = k
c.o = f
h.t = f
assert f.z.t.z.t.z.t.z.t.txt == "f"