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

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

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

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

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

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

k = A("k")
h = B("h")
c = C("c")
g = D("g")
b = E("b")
m = F("m")

k.p = m
k.t = c
k.v = g
h.x = k
h.p = k
h.t = k
h.y = b
c.w = m
c.v = b
c.u = h
c.q = h
g.s = k
g.u = m
b.r = k
b.o = c
m.v = c
m.q = h
m.x = b
assert g.u.x.o.txt == "
class A:
    def __init__(self, txt: str):
        self.p: F = None
        self.t: C = None
        self.v: D = None
        self.txt = txt

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

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

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

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

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

k = A("k")
h = B("h")
c = C("c")
g = D("g")
b = E("b")
m = F("m")

k.p = m
k.t = c
k.v = g
h.x = k
h.p = k
h.t = k
h.y = b
c.w = m
c.v = b
c.u = h
c.q = h
g.s = k
g.u = m
b.r = k
b.o = c
m.v = c
m.q = h
m.x = b
assert g.u.x.o.txt == "c"