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

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

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

class D:
    def __init__(self, txt: str):
        self.y: B = None
        self.u: C = None
        self.z: B = None
        self.txt = txt

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

class F:
    def __init__(self, txt: str):
        self.y: A = None
        self.v: D = None
        self.q: A = None
        self.s: E = None
        self.r: D = None
        self.t: C = None
        self.txt = txt

g = A("g")
k = B("k")
a = C("a")
n = D("n")
f = E("f")
b = F("b")

g.r = a
k.p = b
a.z = n
n.y = k
n.z = k
n.u = a
f.x = g
f.y = k
f.p = a
f.t = b
b.y = g
b.q = g
b.v = n
b.r = n
b.s = f
b.t = a
assert n.u.z.u.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.y: B = None
        self.u: C = None
        self.z: B = None
        self.txt = txt

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

class F:
    def __init__(self, txt: str):
        self.y: A = None
        self.v: D = None
        self.q: A = None
        self.s: E = None
        self.r: D = None
        self.t: C = None
        self.txt = txt

g = A("g")
k = B("k")
a = C("a")
n = D("n")
f = E("f")
b = F("b")

g.r = a
k.p = b
a.z = n
n.y = k
n.z = k
n.u = a
f.x = g
f.y = k
f.p = a
f.t = b
b.y = g
b.q = g
b.v = n
b.r = n
b.s = f
b.t = a
assert n.u.z.u.txt == "a"