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

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.s: B = None
        self.txt = txt

f = A("f")
h = B("h")
b = C("b")
n = D("n")
k = E("k")
e = F("e")

f.z = b
h.r = k
h.x = n
b.w = k
b.p = k
b.u = e
n.r = k
n.t = e
n.o = h
k.p = h
k.q = h
k.t = h
k.o = e
k.r = f
k.x = b
e.s = h
assert k.x.u.s.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.txt = txt

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.s: B = None
        self.txt = txt

f = A("f")
h = B("h")
b = C("b")
n = D("n")
k = E("k")
e = F("e")

f.z = b
h.r = k
h.x = n
b.w = k
b.p = k
b.u = e
n.r = k
n.t = e
n.o = h
k.p = h
k.q = h
k.t = h
k.o = e
k.r = f
k.x = b
e.s = h
assert k.x.u.s.r.r.txt == "f"