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

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

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

class D:
    def __init__(self, txt: str):
        self.r: A = None
        self.q: C = None
        self.w: A = None
        self.t: B = None
        self.p: E = None
        self.u: E = None
        self.txt = txt

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

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

f = A("f")
d = B("d")
g = C("g")
k = D("k")
i = E("i")
m = F("m")
h = F("h")
j = E("j")

f.z = k
f.r = g
d.s = h
g.q = h
k.r = f
k.w = f
k.q = g
k.t = d
k.p = j
k.u = j
i.v = f
i.s = f
i.x = g
m.r = j
m.q = k
h.r = i
h.q = k
j.v = f
j.s = f
j.x = g
assert i.x.q.r.x.q.txt == "
class A:
    def __init__(self, txt: str):
        self.z: D = None
        self.r: C = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.r: A = None
        self.q: C = None
        self.w: A = None
        self.t: B = None
        self.p: E = None
        self.u: E = None
        self.txt = txt

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

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

f = A("f")
d = B("d")
g = C("g")
k = D("k")
i = E("i")
m = F("m")
h = F("h")
j = E("j")

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