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

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

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

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

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

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

g = A("g")
d = B("d")
i = C("i")
n = D("n")
k = E("k")
h = F("h")

g.o = d
d.z = g
i.r = n
n.x = h
n.s = h
n.r = d
n.p = d
k.v = n
k.r = d
k.w = g
h.o = n
h.y = i
h.v = i
h.t = k
assert d.z.o.z.o.z.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.txt = txt

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

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

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

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

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

g = A("g")
d = B("d")
i = C("i")
n = D("n")
k = E("k")
h = F("h")

g.o = d
d.z = g
i.r = n
n.x = h
n.s = h
n.r = d
n.p = d
k.v = n
k.r = d
k.w = g
h.o = n
h.y = i
h.v = i
h.t = k
assert d.z.o.z.o.z.txt == "g"