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

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

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

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

class E:
    def __init__(self, txt: str):
        self.u: F = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.v: A = None
        self.q: C = None
        self.z: E = None
        self.x: E = None
        self.r: C = None
        self.txt = txt

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

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

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

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

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

class E:
    def __init__(self, txt: str):
        self.u: F = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.v: A = None
        self.q: C = None
        self.z: E = None
        self.x: E = None
        self.r: C = None
        self.txt = txt

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

i.q = k
a.x = f
a.t = g
a.z = i
k.x = i
g.t = h
f.u = h
h.v = i
h.q = k
h.r = k
h.z = d
h.x = d
d.u = h
assert d.u.v.q.x.q.x.q.txt == "k"