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

class B:
    def __init__(self, txt: str):
        self.p: C = None
        self.r: A = None
        self.y: A = None
        self.t: F = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.o: B = None
        self.w: A = None
        self.p: A = None
        self.r: A = None
        self.t: F = None
        self.z: D = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.s: B = None
        self.o: D = None
        self.t: B = None
        self.txt = txt

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

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

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

class B:
    def __init__(self, txt: str):
        self.p: C = None
        self.r: A = None
        self.y: A = None
        self.t: F = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.o: B = None
        self.w: A = None
        self.p: A = None
        self.r: A = None
        self.t: F = None
        self.z: D = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.s: B = None
        self.o: D = None
        self.t: B = None
        self.txt = txt

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

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

i.u = m
g.p = m
g.r = i
g.y = i
g.t = k
m.o = g
m.w = i
m.p = i
m.r = i
m.t = k
m.z = a
a.x = i
a.p = b
b.s = g
b.t = g
b.o = a
k.x = a
assert m.t.x.x.txt == "i"