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

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

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

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

class E:
    def __init__(self, txt: str):
        self.q: F = None
        self.v: B = None
        self.y: A = None
        self.u: B = None
        self.txt = txt

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

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

i.x = k
a.r = h
a.z = m
k.r = i
k.z = m
g.x = i
g.q = m
g.p = m
g.r = m
g.w = h
h.q = m
h.v = a
h.u = a
h.y = i
m.o = g
m.u = i
m.w = h
assert m.u.x.z.o.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.q: F = None
        self.v: B = None
        self.y: A = None
        self.u: B = None
        self.txt = txt

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

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

i.x = k
a.r = h
a.z = m
k.r = i
k.z = m
g.x = i
g.q = m
g.p = m
g.r = m
g.w = h
h.q = m
h.v = a
h.u = a
h.y = i
m.o = g
m.u = i
m.w = h
assert m.u.x.z.o.txt == "g"