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

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

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

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

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

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

d = A("d")
k = B("k")
m = C("m")
a = D("a")
f = E("f")
l = F("l")
j = B("j")
c = D("c")
h = A("h")
e = F("e")

d.q = k
k.q = f
k.v = j
k.t = j
k.o = l
m.p = k
m.v = h
m.u = h
a.q = j
a.u = k
f.s = k
l.s = m
j.q = f
j.v = k
j.t = k
j.o = l
c.q = k
c.u = j
h.q = j
e.s = m
assert k.o.s.u.q.o.s.u.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.txt = txt

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

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

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

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

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

d = A("d")
k = B("k")
m = C("m")
a = D("a")
f = E("f")
l = F("l")
j = B("j")
c = D("c")
h = A("h")
e = F("e")

d.q = k
k.q = f
k.v = j
k.t = j
k.o = l
m.p = k
m.v = h
m.u = h
a.q = j
a.u = k
f.s = k
l.s = m
j.q = f
j.v = k
j.t = k
j.o = l
c.q = k
c.u = j
h.q = j
e.s = m
assert k.o.s.u.q.o.s.u.q.q.txt == "f"