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

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

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

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

class E:
    def __init__(self, txt: str):
        self.o: D = None
        self.q: B = None
        self.v: C = None
        self.s: A = None
        self.p: A = None
        self.r: B = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.v: C = None
        self.s: A = None
        self.t: C = None
        self.u: C = None
        self.w: C = None
        self.txt = txt

h = A("h")
k = B("k")
j = C("j")
l = D("l")
f = E("f")
i = F("i")

h.r = i
k.t = h
j.t = f
j.x = i
l.o = h
l.z = h
f.o = l
f.q = k
f.r = k
f.v = j
f.s = h
f.p = h
i.v = j
i.t = j
i.u = j
i.w = j
i.s = h
assert f.q.t.r.s.r.t.txt == "
class A:
    def __init__(self, txt: str):
        self.r: F = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.o: D = None
        self.q: B = None
        self.v: C = None
        self.s: A = None
        self.p: A = None
        self.r: B = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.v: C = None
        self.s: A = None
        self.t: C = None
        self.u: C = None
        self.w: C = None
        self.txt = txt

h = A("h")
k = B("k")
j = C("j")
l = D("l")
f = E("f")
i = F("i")

h.r = i
k.t = h
j.t = f
j.x = i
l.o = h
l.z = h
f.o = l
f.q = k
f.r = k
f.v = j
f.s = h
f.p = h
i.v = j
i.t = j
i.u = j
i.w = j
i.s = h
assert f.q.t.r.s.r.t.txt == "j"