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

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

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

class D:
    def __init__(self, txt: str):
        self.x: E = None
        self.u: F = None
        self.y: C = None
        self.s: E = None
        self.r: E = None
        self.txt = txt

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

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

b = A("b")
m = B("m")
i = C("i")
d = D("d")
c = E("c")
e = F("e")
n = E("n")

b.u = i
b.p = i
b.x = c
m.t = i
m.o = i
i.r = b
d.x = n
d.s = n
d.u = e
d.y = i
d.r = c
c.v = n
c.q = n
c.w = i
c.o = e
e.y = m
n.v = c
n.q = c
n.w = i
n.o = e
assert n.w.r.p.r.x.o.y.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.p: C = None
        self.x: E = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.x: E = None
        self.u: F = None
        self.y: C = None
        self.s: E = None
        self.r: E = None
        self.txt = txt

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

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

b = A("b")
m = B("m")
i = C("i")
d = D("d")
c = E("c")
e = F("e")
n = E("n")

b.u = i
b.p = i
b.x = c
m.t = i
m.o = i
i.r = b
d.x = n
d.s = n
d.u = e
d.y = i
d.r = c
c.v = n
c.q = n
c.w = i
c.o = e
e.y = m
n.v = c
n.q = c
n.w = i
n.o = e
assert n.w.r.p.r.x.o.y.txt == "m"