class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.t: E = None
        self.txt = txt

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

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

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

k = A("k")
c = B("c")
l = C("l")
g = D("g")
h = E("h")
f = F("f")

k.o = c
c.p = k
c.q = k
c.x = h
l.t = h
g.w = k
g.u = k
g.q = k
g.z = f
h.w = g
h.x = g
h.z = k
h.q = c
h.t = l
f.o = k
f.u = c
f.x = g
assert c.p.o.p.o.p.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.t: E = None
        self.txt = txt

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

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

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

k = A("k")
c = B("c")
l = C("l")
g = D("g")
h = E("h")
f = F("f")

k.o = c
c.p = k
c.q = k
c.x = h
l.t = h
g.w = k
g.u = k
g.q = k
g.z = f
h.w = g
h.x = g
h.z = k
h.q = c
h.t = l
f.o = k
f.u = c
f.x = g
assert c.p.o.p.o.p.o.txt == "c"