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

class B:
    def __init__(self, txt: str):
        self.p: D = None
        self.x: A = None
        self.r: D = 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.q: C = None
        self.o: E = None
        self.r: F = None
        self.v: F = None
        self.txt = txt

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

class F:
    def __init__(self, txt: str):
        self.x: C = None
        self.u: D = None
        self.z: D = None
        self.w: C = None
        self.txt = txt

d = A("d")
k = B("k")
a = C("a")
g = D("g")
m = E("m")
j = F("j")

d.q = j
d.o = m
k.p = g
k.r = g
k.x = d
a.x = d
g.q = a
g.o = m
g.r = j
g.v = j
m.u = g
m.s = g
m.z = a
m.t = k
m.x = k
j.x = a
j.w = a
j.u = g
j.z = g
assert d.q.z.o.z.x.o.txt == "
class A:
    def __init__(self, txt: str):
        self.q: F = None
        self.o: E = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.p: D = None
        self.x: A = None
        self.r: D = 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.q: C = None
        self.o: E = None
        self.r: F = None
        self.v: F = None
        self.txt = txt

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

class F:
    def __init__(self, txt: str):
        self.x: C = None
        self.u: D = None
        self.z: D = None
        self.w: C = None
        self.txt = txt

d = A("d")
k = B("k")
a = C("a")
g = D("g")
m = E("m")
j = F("j")

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