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

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

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

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

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

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

g = A("g")
b = B("b")
h = C("h")
m = D("m")
n = E("n")
j = F("j")
d = C("d")
i = B("i")

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

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

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

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

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

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

g = A("g")
b = B("b")
h = C("h")
m = D("m")
n = E("n")
j = F("j")
d = C("d")
i = B("i")

g.u = b
g.p = i
g.v = n
b.v = i
b.p = m
h.v = g
m.p = i
m.w = b
n.x = j
n.o = g
n.t = g
n.y = i
n.w = i
j.q = i
j.x = d
j.o = m
j.t = b
j.w = h
j.v = n
d.v = g
i.v = b
i.p = m
assert m.w.v.p.w.v.txt == "i"