class A:
    def __init__(self, txt: str):
        self.o: E = None
        self.u: D = None
        self.q: D = None
        self.v: B = None
        self.txt = txt

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.w: A = None
        self.x: D = None
        self.t: C = None
        self.s: C = None
        self.txt = txt

h = A("h")
d = B("d")
a = C("a")
g = D("g")
b = E("b")
n = F("n")

h.o = b
h.u = g
h.q = g
h.v = d
d.y = a
d.v = h
d.q = n
a.v = g
a.x = h
a.r = h
g.r = b
g.q = n
b.q = d
b.p = d
b.x = a
n.w = h
n.x = g
n.t = a
n.s = a
assert g.r.x.v.q.txt == "
class A:
    def __init__(self, txt: str):
        self.o: E = None
        self.u: D = None
        self.q: D = None
        self.v: B = None
        self.txt = txt

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.w: A = None
        self.x: D = None
        self.t: C = None
        self.s: C = None
        self.txt = txt

h = A("h")
d = B("d")
a = C("a")
g = D("g")
b = E("b")
n = F("n")

h.o = b
h.u = g
h.q = g
h.v = d
d.y = a
d.v = h
d.q = n
a.v = g
a.x = h
a.r = h
g.r = b
g.q = n
b.q = d
b.p = d
b.x = a
n.w = h
n.x = g
n.t = a
n.s = a
assert g.r.x.v.q.txt == "n"